documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. 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>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. 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;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  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 LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * 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)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @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
  4923. * @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
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. 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);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. _getVertexShaderCode(): string | null;
  7177. _getFragmentShaderCode(): string | null;
  7178. }
  7179. }
  7180. declare module BABYLON {
  7181. interface ThinEngine {
  7182. /**
  7183. * Create an uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param elements defines the content of the uniform buffer
  7186. * @returns the webGL uniform buffer
  7187. */
  7188. createUniformBuffer(elements: FloatArray): DataBuffer;
  7189. /**
  7190. * Create a dynamic uniform buffer
  7191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7192. * @param elements defines the content of the uniform buffer
  7193. * @returns the webGL uniform buffer
  7194. */
  7195. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7196. /**
  7197. * Update an existing uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param uniformBuffer defines the target uniform buffer
  7200. * @param elements defines the content to update
  7201. * @param offset defines the offset in the uniform buffer where update should start
  7202. * @param count defines the size of the data to update
  7203. */
  7204. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7205. /**
  7206. * Bind an uniform buffer to the current webGL context
  7207. * @param buffer defines the buffer to bind
  7208. */
  7209. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7210. /**
  7211. * Bind a buffer to the current webGL context at a given location
  7212. * @param buffer defines the buffer to bind
  7213. * @param location defines the index where to bind the buffer
  7214. */
  7215. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7216. /**
  7217. * Bind a specific block at a given index in a specific shader program
  7218. * @param pipelineContext defines the pipeline context to use
  7219. * @param blockName defines the block name
  7220. * @param index defines the index where to bind the block
  7221. */
  7222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7223. }
  7224. }
  7225. declare module BABYLON {
  7226. /**
  7227. * Uniform buffer objects.
  7228. *
  7229. * Handles blocks of uniform on the GPU.
  7230. *
  7231. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7232. *
  7233. * For more information, please refer to :
  7234. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7235. */
  7236. export class UniformBuffer {
  7237. private _engine;
  7238. private _buffer;
  7239. private _data;
  7240. private _bufferData;
  7241. private _dynamic?;
  7242. private _uniformLocations;
  7243. private _uniformSizes;
  7244. private _uniformLocationPointer;
  7245. private _needSync;
  7246. private _noUBO;
  7247. private _currentEffect;
  7248. /** @hidden */
  7249. _alreadyBound: boolean;
  7250. private static _MAX_UNIFORM_SIZE;
  7251. private static _tempBuffer;
  7252. /**
  7253. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7254. * This is dynamic to allow compat with webgl 1 and 2.
  7255. * You will need to pass the name of the uniform as well as the value.
  7256. */
  7257. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7258. /**
  7259. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7260. * This is dynamic to allow compat with webgl 1 and 2.
  7261. * You will need to pass the name of the uniform as well as the value.
  7262. */
  7263. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7264. /**
  7265. * Lambda to Update a single float in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateFloat: (name: string, x: number) => void;
  7270. /**
  7271. * Lambda to Update a vec2 of float in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7276. /**
  7277. * Lambda to Update a vec3 of float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7282. /**
  7283. * Lambda to Update a vec4 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateMatrix: (name: string, mat: Matrix) => void;
  7294. /**
  7295. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateVector3: (name: string, vector: Vector3) => void;
  7300. /**
  7301. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateVector4: (name: string, vector: Vector4) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7318. /**
  7319. * Instantiates a new Uniform buffer objects.
  7320. *
  7321. * Handles blocks of uniform on the GPU.
  7322. *
  7323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7324. *
  7325. * For more information, please refer to :
  7326. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7327. * @param engine Define the engine the buffer is associated with
  7328. * @param data Define the data contained in the buffer
  7329. * @param dynamic Define if the buffer is updatable
  7330. */
  7331. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7332. /**
  7333. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7334. * or just falling back on setUniformXXX calls.
  7335. */
  7336. get useUbo(): boolean;
  7337. /**
  7338. * Indicates if the WebGL underlying uniform buffer is in sync
  7339. * with the javascript cache data.
  7340. */
  7341. get isSync(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7344. * Also, a dynamic UniformBuffer will disable cache verification and always
  7345. * update the underlying WebGL uniform buffer to the GPU.
  7346. * @returns if Dynamic, otherwise false
  7347. */
  7348. isDynamic(): boolean;
  7349. /**
  7350. * The data cache on JS side.
  7351. * @returns the underlying data as a float array
  7352. */
  7353. getData(): Float32Array;
  7354. /**
  7355. * The underlying WebGL Uniform buffer.
  7356. * @returns the webgl buffer
  7357. */
  7358. getBuffer(): Nullable<DataBuffer>;
  7359. /**
  7360. * std140 layout specifies how to align data within an UBO structure.
  7361. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7362. * for specs.
  7363. */
  7364. private _fillAlignment;
  7365. /**
  7366. * Adds an uniform in the buffer.
  7367. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7368. * for the layout to be correct !
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param size Data size, or data directly.
  7371. */
  7372. addUniform(name: string, size: number | number[]): void;
  7373. /**
  7374. * Adds a Matrix 4x4 to the uniform buffer.
  7375. * @param name Name of the uniform, as used in the uniform block in the shader.
  7376. * @param mat A 4x4 matrix.
  7377. */
  7378. addMatrix(name: string, mat: Matrix): void;
  7379. /**
  7380. * Adds a vec2 to the uniform buffer.
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param x Define the x component value of the vec2
  7383. * @param y Define the y component value of the vec2
  7384. */
  7385. addFloat2(name: string, x: number, y: number): void;
  7386. /**
  7387. * Adds a vec3 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param x Define the x component value of the vec3
  7390. * @param y Define the y component value of the vec3
  7391. * @param z Define the z component value of the vec3
  7392. */
  7393. addFloat3(name: string, x: number, y: number, z: number): void;
  7394. /**
  7395. * Adds a vec3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param color Define the vec3 from a Color
  7398. */
  7399. addColor3(name: string, color: Color3): void;
  7400. /**
  7401. * Adds a vec4 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param color Define the rgb components from a Color
  7404. * @param alpha Define the a component of the vec4
  7405. */
  7406. addColor4(name: string, color: Color3, alpha: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param vector Define the vec3 components from a Vector
  7411. */
  7412. addVector3(name: string, vector: Vector3): void;
  7413. /**
  7414. * Adds a Matrix 3x3 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. */
  7417. addMatrix3x3(name: string): void;
  7418. /**
  7419. * Adds a Matrix 2x2 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix2x2(name: string): void;
  7423. /**
  7424. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7425. */
  7426. create(): void;
  7427. /** @hidden */
  7428. _rebuild(): void;
  7429. /**
  7430. * Updates the WebGL Uniform Buffer on the GPU.
  7431. * If the `dynamic` flag is set to true, no cache comparison is done.
  7432. * Otherwise, the buffer will be updated only if the cache differs.
  7433. */
  7434. update(): void;
  7435. /**
  7436. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7438. * @param data Define the flattened data
  7439. * @param size Define the size of the data.
  7440. */
  7441. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7442. private _valueCache;
  7443. private _cacheMatrix;
  7444. private _updateMatrix3x3ForUniform;
  7445. private _updateMatrix3x3ForEffect;
  7446. private _updateMatrix2x2ForEffect;
  7447. private _updateMatrix2x2ForUniform;
  7448. private _updateFloatForEffect;
  7449. private _updateFloatForUniform;
  7450. private _updateFloat2ForEffect;
  7451. private _updateFloat2ForUniform;
  7452. private _updateFloat3ForEffect;
  7453. private _updateFloat3ForUniform;
  7454. private _updateFloat4ForEffect;
  7455. private _updateFloat4ForUniform;
  7456. private _updateMatrixForEffect;
  7457. private _updateMatrixForUniform;
  7458. private _updateVector3ForEffect;
  7459. private _updateVector3ForUniform;
  7460. private _updateVector4ForEffect;
  7461. private _updateVector4ForUniform;
  7462. private _updateColor3ForEffect;
  7463. private _updateColor3ForUniform;
  7464. private _updateColor4ForEffect;
  7465. private _updateColor4ForUniform;
  7466. /**
  7467. * Sets a sampler uniform on the effect.
  7468. * @param name Define the name of the sampler.
  7469. * @param texture Define the texture to set in the sampler
  7470. */
  7471. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7472. /**
  7473. * Directly updates the value of the uniform in the cache AND on the GPU.
  7474. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7475. * @param data Define the flattened data
  7476. */
  7477. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7478. /**
  7479. * Binds this uniform buffer to an effect.
  7480. * @param effect Define the effect to bind the buffer to
  7481. * @param name Name of the uniform block in the shader.
  7482. */
  7483. bindToEffect(effect: Effect, name: string): void;
  7484. /**
  7485. * Disposes the uniform buffer.
  7486. */
  7487. dispose(): void;
  7488. }
  7489. }
  7490. declare module BABYLON {
  7491. /**
  7492. * Enum that determines the text-wrapping mode to use.
  7493. */
  7494. export enum InspectableType {
  7495. /**
  7496. * Checkbox for booleans
  7497. */
  7498. Checkbox = 0,
  7499. /**
  7500. * Sliders for numbers
  7501. */
  7502. Slider = 1,
  7503. /**
  7504. * Vector3
  7505. */
  7506. Vector3 = 2,
  7507. /**
  7508. * Quaternions
  7509. */
  7510. Quaternion = 3,
  7511. /**
  7512. * Color3
  7513. */
  7514. Color3 = 4,
  7515. /**
  7516. * String
  7517. */
  7518. String = 5
  7519. }
  7520. /**
  7521. * Interface used to define custom inspectable properties.
  7522. * This interface is used by the inspector to display custom property grids
  7523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7524. */
  7525. export interface IInspectable {
  7526. /**
  7527. * Gets the label to display
  7528. */
  7529. label: string;
  7530. /**
  7531. * Gets the name of the property to edit
  7532. */
  7533. propertyName: string;
  7534. /**
  7535. * Gets the type of the editor to use
  7536. */
  7537. type: InspectableType;
  7538. /**
  7539. * Gets the minimum value of the property when using in "slider" mode
  7540. */
  7541. min?: number;
  7542. /**
  7543. * Gets the maximum value of the property when using in "slider" mode
  7544. */
  7545. max?: number;
  7546. /**
  7547. * Gets the setp to use when using in "slider" mode
  7548. */
  7549. step?: number;
  7550. }
  7551. }
  7552. declare module BABYLON {
  7553. /**
  7554. * Class used to provide helper for timing
  7555. */
  7556. export class TimingTools {
  7557. /**
  7558. * Polyfill for setImmediate
  7559. * @param action defines the action to execute after the current execution block
  7560. */
  7561. static SetImmediate(action: () => void): void;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to enable instatition of objects by class name
  7567. */
  7568. export class InstantiationTools {
  7569. /**
  7570. * Use this object to register external classes like custom textures or material
  7571. * to allow the laoders to instantiate them
  7572. */
  7573. static RegisteredExternalClasses: {
  7574. [key: string]: Object;
  7575. };
  7576. /**
  7577. * Tries to instantiate a new object from a given class name
  7578. * @param className defines the class name to instantiate
  7579. * @returns the new object or null if the system was not able to do the instantiation
  7580. */
  7581. static Instantiate(className: string): any;
  7582. }
  7583. }
  7584. declare module BABYLON {
  7585. /**
  7586. * Define options used to create a depth texture
  7587. */
  7588. export class DepthTextureCreationOptions {
  7589. /** Specifies whether or not a stencil should be allocated in the texture */
  7590. generateStencil?: boolean;
  7591. /** Specifies whether or not bilinear filtering is enable on the texture */
  7592. bilinearFiltering?: boolean;
  7593. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7594. comparisonFunction?: number;
  7595. /** Specifies if the created texture is a cube texture */
  7596. isCube?: boolean;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. interface ThinEngine {
  7601. /**
  7602. * Creates a depth stencil cube texture.
  7603. * This is only available in WebGL 2.
  7604. * @param size The size of face edge in the cube texture.
  7605. * @param options The options defining the cube texture.
  7606. * @returns The cube texture
  7607. */
  7608. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7609. /**
  7610. * Creates a cube texture
  7611. * @param rootUrl defines the url where the files to load is located
  7612. * @param scene defines the current scene
  7613. * @param files defines the list of files to load (1 per face)
  7614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7615. * @param onLoad defines an optional callback raised when the texture is loaded
  7616. * @param onError defines an optional callback raised if there is an issue to load the texture
  7617. * @param format defines the format of the data
  7618. * @param forcedExtension defines the extension to use to pick the right loader
  7619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7622. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7623. * @returns the cube texture as an InternalTexture
  7624. */
  7625. 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;
  7626. /**
  7627. * Creates a cube texture
  7628. * @param rootUrl defines the url where the files to load is located
  7629. * @param scene defines the current scene
  7630. * @param files defines the list of files to load (1 per face)
  7631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7632. * @param onLoad defines an optional callback raised when the texture is loaded
  7633. * @param onError defines an optional callback raised if there is an issue to load the texture
  7634. * @param format defines the format of the data
  7635. * @param forcedExtension defines the extension to use to pick the right loader
  7636. * @returns the cube texture as an InternalTexture
  7637. */
  7638. 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;
  7639. /**
  7640. * Creates a cube texture
  7641. * @param rootUrl defines the url where the files to load is located
  7642. * @param scene defines the current scene
  7643. * @param files defines the list of files to load (1 per face)
  7644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7645. * @param onLoad defines an optional callback raised when the texture is loaded
  7646. * @param onError defines an optional callback raised if there is an issue to load the texture
  7647. * @param format defines the format of the data
  7648. * @param forcedExtension defines the extension to use to pick the right loader
  7649. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7652. * @returns the cube texture as an InternalTexture
  7653. */
  7654. 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;
  7655. /** @hidden */
  7656. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7657. /** @hidden */
  7658. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7659. /** @hidden */
  7660. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7661. /** @hidden */
  7662. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7663. /**
  7664. * @hidden
  7665. */
  7666. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7667. }
  7668. }
  7669. declare module BABYLON {
  7670. /**
  7671. * Class for creating a cube texture
  7672. */
  7673. export class CubeTexture extends BaseTexture {
  7674. private _delayedOnLoad;
  7675. /**
  7676. * Observable triggered once the texture has been loaded.
  7677. */
  7678. onLoadObservable: Observable<CubeTexture>;
  7679. /**
  7680. * The url of the texture
  7681. */
  7682. url: string;
  7683. /**
  7684. * Gets or sets the center of the bounding box associated with the cube texture.
  7685. * It must define where the camera used to render the texture was set
  7686. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7687. */
  7688. boundingBoxPosition: Vector3;
  7689. private _boundingBoxSize;
  7690. /**
  7691. * Gets or sets the size of the bounding box associated with the cube texture
  7692. * When defined, the cubemap will switch to local mode
  7693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7694. * @example https://www.babylonjs-playground.com/#RNASML
  7695. */
  7696. set boundingBoxSize(value: Vector3);
  7697. /**
  7698. * Returns the bounding box size
  7699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7700. */
  7701. get boundingBoxSize(): Vector3;
  7702. protected _rotationY: number;
  7703. /**
  7704. * Sets texture matrix rotation angle around Y axis in radians.
  7705. */
  7706. set rotationY(value: number);
  7707. /**
  7708. * Gets texture matrix rotation angle around Y axis radians.
  7709. */
  7710. get rotationY(): number;
  7711. /**
  7712. * Are mip maps generated for this texture or not.
  7713. */
  7714. get noMipmap(): boolean;
  7715. private _noMipmap;
  7716. private _files;
  7717. protected _forcedExtension: Nullable<string>;
  7718. private _extensions;
  7719. private _textureMatrix;
  7720. private _format;
  7721. private _createPolynomials;
  7722. /** @hidden */
  7723. _prefiltered: boolean;
  7724. /**
  7725. * Creates a cube texture from an array of image urls
  7726. * @param files defines an array of image urls
  7727. * @param scene defines the hosting scene
  7728. * @param noMipmap specifies if mip maps are not used
  7729. * @returns a cube texture
  7730. */
  7731. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7732. /**
  7733. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7734. * @param url defines the url of the prefiltered texture
  7735. * @param scene defines the scene the texture is attached to
  7736. * @param forcedExtension defines the extension of the file if different from the url
  7737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7738. * @return the prefiltered texture
  7739. */
  7740. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7741. /**
  7742. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7743. * as prefiltered data.
  7744. * @param rootUrl defines the url of the texture or the root name of the six images
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7747. * @param noMipmap defines if mipmaps should be created or not
  7748. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7749. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7750. * @param onError defines a callback triggered in case of error during load
  7751. * @param format defines the internal format to use for the texture once loaded
  7752. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7753. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7757. * @return the cube texture
  7758. */
  7759. 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);
  7760. /**
  7761. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7762. */
  7763. get isPrefiltered(): boolean;
  7764. /**
  7765. * Get the current class name of the texture useful for serialization or dynamic coding.
  7766. * @returns "CubeTexture"
  7767. */
  7768. getClassName(): string;
  7769. /**
  7770. * Update the url (and optional buffer) of this texture if url was null during construction.
  7771. * @param url the url of the texture
  7772. * @param forcedExtension defines the extension to use
  7773. * @param onLoad callback called when the texture is loaded (defaults to null)
  7774. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7775. */
  7776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7777. /**
  7778. * Delays loading of the cube texture
  7779. * @param forcedExtension defines the extension to use
  7780. */
  7781. delayLoad(forcedExtension?: string): void;
  7782. /**
  7783. * Returns the reflection texture matrix
  7784. * @returns the reflection texture matrix
  7785. */
  7786. getReflectionTextureMatrix(): Matrix;
  7787. /**
  7788. * Sets the reflection texture matrix
  7789. * @param value Reflection texture matrix
  7790. */
  7791. setReflectionTextureMatrix(value: Matrix): void;
  7792. /**
  7793. * Parses text to create a cube texture
  7794. * @param parsedTexture define the serialized text to read from
  7795. * @param scene defines the hosting scene
  7796. * @param rootUrl defines the root url of the cube texture
  7797. * @returns a cube texture
  7798. */
  7799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7800. /**
  7801. * Makes a clone, or deep copy, of the cube texture
  7802. * @returns a new cube texture
  7803. */
  7804. clone(): CubeTexture;
  7805. }
  7806. }
  7807. declare module BABYLON {
  7808. /**
  7809. * Manages the defines for the Material
  7810. */
  7811. export class MaterialDefines {
  7812. /** @hidden */
  7813. protected _keys: string[];
  7814. private _isDirty;
  7815. /** @hidden */
  7816. _renderId: number;
  7817. /** @hidden */
  7818. _areLightsDirty: boolean;
  7819. /** @hidden */
  7820. _areLightsDisposed: boolean;
  7821. /** @hidden */
  7822. _areAttributesDirty: boolean;
  7823. /** @hidden */
  7824. _areTexturesDirty: boolean;
  7825. /** @hidden */
  7826. _areFresnelDirty: boolean;
  7827. /** @hidden */
  7828. _areMiscDirty: boolean;
  7829. /** @hidden */
  7830. _areImageProcessingDirty: boolean;
  7831. /** @hidden */
  7832. _normals: boolean;
  7833. /** @hidden */
  7834. _uvs: boolean;
  7835. /** @hidden */
  7836. _needNormals: boolean;
  7837. /** @hidden */
  7838. _needUVs: boolean;
  7839. [id: string]: any;
  7840. /**
  7841. * Specifies if the material needs to be re-calculated
  7842. */
  7843. get isDirty(): boolean;
  7844. /**
  7845. * Marks the material to indicate that it has been re-calculated
  7846. */
  7847. markAsProcessed(): void;
  7848. /**
  7849. * Marks the material to indicate that it needs to be re-calculated
  7850. */
  7851. markAsUnprocessed(): void;
  7852. /**
  7853. * Marks the material to indicate all of its defines need to be re-calculated
  7854. */
  7855. markAllAsDirty(): void;
  7856. /**
  7857. * Marks the material to indicate that image processing needs to be re-calculated
  7858. */
  7859. markAsImageProcessingDirty(): void;
  7860. /**
  7861. * Marks the material to indicate the lights need to be re-calculated
  7862. * @param disposed Defines whether the light is dirty due to dispose or not
  7863. */
  7864. markAsLightDirty(disposed?: boolean): void;
  7865. /**
  7866. * Marks the attribute state as changed
  7867. */
  7868. markAsAttributesDirty(): void;
  7869. /**
  7870. * Marks the texture state as changed
  7871. */
  7872. markAsTexturesDirty(): void;
  7873. /**
  7874. * Marks the fresnel state as changed
  7875. */
  7876. markAsFresnelDirty(): void;
  7877. /**
  7878. * Marks the misc state as changed
  7879. */
  7880. markAsMiscDirty(): void;
  7881. /**
  7882. * Rebuilds the material defines
  7883. */
  7884. rebuild(): void;
  7885. /**
  7886. * Specifies if two material defines are equal
  7887. * @param other - A material define instance to compare to
  7888. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7889. */
  7890. isEqual(other: MaterialDefines): boolean;
  7891. /**
  7892. * Clones this instance's defines to another instance
  7893. * @param other - material defines to clone values to
  7894. */
  7895. cloneTo(other: MaterialDefines): void;
  7896. /**
  7897. * Resets the material define values
  7898. */
  7899. reset(): void;
  7900. /**
  7901. * Converts the material define values to a string
  7902. * @returns - String of material define information
  7903. */
  7904. toString(): string;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7911. * 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;
  7912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7913. */
  7914. export class ColorCurves {
  7915. private _dirty;
  7916. private _tempColor;
  7917. private _globalCurve;
  7918. private _highlightsCurve;
  7919. private _midtonesCurve;
  7920. private _shadowsCurve;
  7921. private _positiveCurve;
  7922. private _negativeCurve;
  7923. private _globalHue;
  7924. private _globalDensity;
  7925. private _globalSaturation;
  7926. private _globalExposure;
  7927. /**
  7928. * Gets the global Hue value.
  7929. * 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).
  7930. */
  7931. get globalHue(): number;
  7932. /**
  7933. * Sets the global Hue value.
  7934. * 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).
  7935. */
  7936. set globalHue(value: number);
  7937. /**
  7938. * Gets the global Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. get globalDensity(): number;
  7943. /**
  7944. * Sets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. set globalDensity(value: number);
  7949. /**
  7950. * Gets the global Saturation value.
  7951. * 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.
  7952. */
  7953. get globalSaturation(): number;
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * 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.
  7957. */
  7958. set globalSaturation(value: number);
  7959. /**
  7960. * Gets the global Exposure value.
  7961. * 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.
  7962. */
  7963. get globalExposure(): number;
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. set globalExposure(value: number);
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. get highlightsHue(): number;
  7978. /**
  7979. * Sets the highlights Hue value.
  7980. * 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).
  7981. */
  7982. set highlightsHue(value: number);
  7983. /**
  7984. * Gets the highlights Density value.
  7985. * 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.
  7986. * Values less than zero provide a filter of opposite hue.
  7987. */
  7988. get highlightsDensity(): number;
  7989. /**
  7990. * Sets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. set highlightsDensity(value: number);
  7995. /**
  7996. * Gets the highlights Saturation value.
  7997. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7998. */
  7999. get highlightsSaturation(): number;
  8000. /**
  8001. * Sets the highlights Saturation value.
  8002. * 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.
  8003. */
  8004. set highlightsSaturation(value: number);
  8005. /**
  8006. * Gets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. get highlightsExposure(): number;
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * 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.
  8013. */
  8014. set highlightsExposure(value: number);
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. get midtonesHue(): number;
  8024. /**
  8025. * Sets the midtones Hue value.
  8026. * 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).
  8027. */
  8028. set midtonesHue(value: number);
  8029. /**
  8030. * Gets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. get midtonesDensity(): number;
  8035. /**
  8036. * Sets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. set midtonesDensity(value: number);
  8041. /**
  8042. * Gets the midtones Saturation value.
  8043. * 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.
  8044. */
  8045. get midtonesSaturation(): number;
  8046. /**
  8047. * Sets the midtones Saturation value.
  8048. * 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.
  8049. */
  8050. set midtonesSaturation(value: number);
  8051. /**
  8052. * Gets the midtones Exposure value.
  8053. * 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.
  8054. */
  8055. get midtonesExposure(): number;
  8056. /**
  8057. * Sets the midtones Exposure value.
  8058. * 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.
  8059. */
  8060. set midtonesExposure(value: number);
  8061. private _shadowsHue;
  8062. private _shadowsDensity;
  8063. private _shadowsSaturation;
  8064. private _shadowsExposure;
  8065. /**
  8066. * Gets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. get shadowsHue(): number;
  8070. /**
  8071. * Sets the shadows Hue value.
  8072. * 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).
  8073. */
  8074. set shadowsHue(value: number);
  8075. /**
  8076. * Gets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. get shadowsDensity(): number;
  8081. /**
  8082. * Sets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. set shadowsDensity(value: number);
  8087. /**
  8088. * Gets the shadows Saturation value.
  8089. * 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.
  8090. */
  8091. get shadowsSaturation(): number;
  8092. /**
  8093. * Sets the shadows Saturation value.
  8094. * 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.
  8095. */
  8096. set shadowsSaturation(value: number);
  8097. /**
  8098. * Gets the shadows Exposure value.
  8099. * 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.
  8100. */
  8101. get shadowsExposure(): number;
  8102. /**
  8103. * Sets the shadows Exposure value.
  8104. * 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.
  8105. */
  8106. set shadowsExposure(value: number);
  8107. /**
  8108. * Returns the class name
  8109. * @returns The class name
  8110. */
  8111. getClassName(): string;
  8112. /**
  8113. * Binds the color curves to the shader.
  8114. * @param colorCurves The color curve to bind
  8115. * @param effect The effect to bind to
  8116. * @param positiveUniform The positive uniform shader parameter
  8117. * @param neutralUniform The neutral uniform shader parameter
  8118. * @param negativeUniform The negative uniform shader parameter
  8119. */
  8120. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8121. /**
  8122. * Prepare the list of uniforms associated with the ColorCurves effects.
  8123. * @param uniformsList The list of uniforms used in the effect
  8124. */
  8125. static PrepareUniforms(uniformsList: string[]): void;
  8126. /**
  8127. * Returns color grading data based on a hue, density, saturation and exposure value.
  8128. * @param filterHue The hue of the color filter.
  8129. * @param filterDensity The density of the color filter.
  8130. * @param saturation The saturation.
  8131. * @param exposure The exposure.
  8132. * @param result The result data container.
  8133. */
  8134. private getColorGradingDataToRef;
  8135. /**
  8136. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8137. * @param value The input slider value in range [-100,100].
  8138. * @returns Adjusted value.
  8139. */
  8140. private static applyColorGradingSliderNonlinear;
  8141. /**
  8142. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8143. * @param hue The hue (H) input.
  8144. * @param saturation The saturation (S) input.
  8145. * @param brightness The brightness (B) input.
  8146. * @result An RGBA color represented as Vector4.
  8147. */
  8148. private static fromHSBToRef;
  8149. /**
  8150. * Returns a value clamped between min and max
  8151. * @param value The value to clamp
  8152. * @param min The minimum of value
  8153. * @param max The maximum of value
  8154. * @returns The clamped value.
  8155. */
  8156. private static clamp;
  8157. /**
  8158. * Clones the current color curve instance.
  8159. * @return The cloned curves
  8160. */
  8161. clone(): ColorCurves;
  8162. /**
  8163. * Serializes the current color curve instance to a json representation.
  8164. * @return a JSON representation
  8165. */
  8166. serialize(): any;
  8167. /**
  8168. * Parses the color curve from a json representation.
  8169. * @param source the JSON source to parse
  8170. * @return The parsed curves
  8171. */
  8172. static Parse(source: any): ColorCurves;
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /**
  8177. * Interface to follow in your material defines to integrate easily the
  8178. * Image proccessing functions.
  8179. * @hidden
  8180. */
  8181. export interface IImageProcessingConfigurationDefines {
  8182. IMAGEPROCESSING: boolean;
  8183. VIGNETTE: boolean;
  8184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8185. VIGNETTEBLENDMODEOPAQUE: boolean;
  8186. TONEMAPPING: boolean;
  8187. TONEMAPPING_ACES: boolean;
  8188. CONTRAST: boolean;
  8189. EXPOSURE: boolean;
  8190. COLORCURVES: boolean;
  8191. COLORGRADING: boolean;
  8192. COLORGRADING3D: boolean;
  8193. SAMPLER3DGREENDEPTH: boolean;
  8194. SAMPLER3DBGRMAP: boolean;
  8195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8196. }
  8197. /**
  8198. * @hidden
  8199. */
  8200. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. COLORCURVES: boolean;
  8209. COLORGRADING: boolean;
  8210. COLORGRADING3D: boolean;
  8211. SAMPLER3DGREENDEPTH: boolean;
  8212. SAMPLER3DBGRMAP: boolean;
  8213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8214. EXPOSURE: boolean;
  8215. constructor();
  8216. }
  8217. /**
  8218. * This groups together the common properties used for image processing either in direct forward pass
  8219. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8220. * or not.
  8221. */
  8222. export class ImageProcessingConfiguration {
  8223. /**
  8224. * Default tone mapping applied in BabylonJS.
  8225. */
  8226. static readonly TONEMAPPING_STANDARD: number;
  8227. /**
  8228. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8229. * to other engines rendering to increase portability.
  8230. */
  8231. static readonly TONEMAPPING_ACES: number;
  8232. /**
  8233. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8234. */
  8235. colorCurves: Nullable<ColorCurves>;
  8236. private _colorCurvesEnabled;
  8237. /**
  8238. * Gets wether the color curves effect is enabled.
  8239. */
  8240. get colorCurvesEnabled(): boolean;
  8241. /**
  8242. * Sets wether the color curves effect is enabled.
  8243. */
  8244. set colorCurvesEnabled(value: boolean);
  8245. private _colorGradingTexture;
  8246. /**
  8247. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8248. */
  8249. get colorGradingTexture(): Nullable<BaseTexture>;
  8250. /**
  8251. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8252. */
  8253. set colorGradingTexture(value: Nullable<BaseTexture>);
  8254. private _colorGradingEnabled;
  8255. /**
  8256. * Gets wether the color grading effect is enabled.
  8257. */
  8258. get colorGradingEnabled(): boolean;
  8259. /**
  8260. * Sets wether the color grading effect is enabled.
  8261. */
  8262. set colorGradingEnabled(value: boolean);
  8263. private _colorGradingWithGreenDepth;
  8264. /**
  8265. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8266. */
  8267. get colorGradingWithGreenDepth(): boolean;
  8268. /**
  8269. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8270. */
  8271. set colorGradingWithGreenDepth(value: boolean);
  8272. private _colorGradingBGR;
  8273. /**
  8274. * Gets wether the color grading texture contains BGR values.
  8275. */
  8276. get colorGradingBGR(): boolean;
  8277. /**
  8278. * Sets wether the color grading texture contains BGR values.
  8279. */
  8280. set colorGradingBGR(value: boolean);
  8281. /** @hidden */
  8282. _exposure: number;
  8283. /**
  8284. * Gets the Exposure used in the effect.
  8285. */
  8286. get exposure(): number;
  8287. /**
  8288. * Sets the Exposure used in the effect.
  8289. */
  8290. set exposure(value: number);
  8291. private _toneMappingEnabled;
  8292. /**
  8293. * Gets wether the tone mapping effect is enabled.
  8294. */
  8295. get toneMappingEnabled(): boolean;
  8296. /**
  8297. * Sets wether the tone mapping effect is enabled.
  8298. */
  8299. set toneMappingEnabled(value: boolean);
  8300. private _toneMappingType;
  8301. /**
  8302. * Gets the type of tone mapping effect.
  8303. */
  8304. get toneMappingType(): number;
  8305. /**
  8306. * Sets the type of tone mapping effect used in BabylonJS.
  8307. */
  8308. set toneMappingType(value: number);
  8309. protected _contrast: number;
  8310. /**
  8311. * Gets the contrast used in the effect.
  8312. */
  8313. get contrast(): number;
  8314. /**
  8315. * Sets the contrast used in the effect.
  8316. */
  8317. set contrast(value: number);
  8318. /**
  8319. * Vignette stretch size.
  8320. */
  8321. vignetteStretch: number;
  8322. /**
  8323. * Vignette centre X Offset.
  8324. */
  8325. vignetteCentreX: number;
  8326. /**
  8327. * Vignette centre Y Offset.
  8328. */
  8329. vignetteCentreY: number;
  8330. /**
  8331. * Vignette weight or intensity of the vignette effect.
  8332. */
  8333. vignetteWeight: number;
  8334. /**
  8335. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8336. * if vignetteEnabled is set to true.
  8337. */
  8338. vignetteColor: Color4;
  8339. /**
  8340. * Camera field of view used by the Vignette effect.
  8341. */
  8342. vignetteCameraFov: number;
  8343. private _vignetteBlendMode;
  8344. /**
  8345. * Gets the vignette blend mode allowing different kind of effect.
  8346. */
  8347. get vignetteBlendMode(): number;
  8348. /**
  8349. * Sets the vignette blend mode allowing different kind of effect.
  8350. */
  8351. set vignetteBlendMode(value: number);
  8352. private _vignetteEnabled;
  8353. /**
  8354. * Gets wether the vignette effect is enabled.
  8355. */
  8356. get vignetteEnabled(): boolean;
  8357. /**
  8358. * Sets wether the vignette effect is enabled.
  8359. */
  8360. set vignetteEnabled(value: boolean);
  8361. private _applyByPostProcess;
  8362. /**
  8363. * Gets wether the image processing is applied through a post process or not.
  8364. */
  8365. get applyByPostProcess(): boolean;
  8366. /**
  8367. * Sets wether the image processing is applied through a post process or not.
  8368. */
  8369. set applyByPostProcess(value: boolean);
  8370. private _isEnabled;
  8371. /**
  8372. * Gets wether the image processing is enabled or not.
  8373. */
  8374. get isEnabled(): boolean;
  8375. /**
  8376. * Sets wether the image processing is enabled or not.
  8377. */
  8378. set isEnabled(value: boolean);
  8379. /**
  8380. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8381. */
  8382. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8383. /**
  8384. * Method called each time the image processing information changes requires to recompile the effect.
  8385. */
  8386. protected _updateParameters(): void;
  8387. /**
  8388. * Gets the current class name.
  8389. * @return "ImageProcessingConfiguration"
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Prepare the list of uniforms associated with the Image Processing effects.
  8394. * @param uniforms The list of uniforms used in the effect
  8395. * @param defines the list of defines currently in use
  8396. */
  8397. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8398. /**
  8399. * Prepare the list of samplers associated with the Image Processing effects.
  8400. * @param samplersList The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of defines associated to the shader.
  8406. * @param defines the list of defines to complete
  8407. * @param forPostProcess Define if we are currently in post process mode or not
  8408. */
  8409. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8410. /**
  8411. * Returns true if all the image processing information are ready.
  8412. * @returns True if ready, otherwise, false
  8413. */
  8414. isReady(): boolean;
  8415. /**
  8416. * Binds the image processing to the shader.
  8417. * @param effect The effect to bind to
  8418. * @param overrideAspectRatio Override the aspect ratio of the effect
  8419. */
  8420. bind(effect: Effect, overrideAspectRatio?: number): void;
  8421. /**
  8422. * Clones the current image processing instance.
  8423. * @return The cloned image processing
  8424. */
  8425. clone(): ImageProcessingConfiguration;
  8426. /**
  8427. * Serializes the current image processing instance to a json representation.
  8428. * @return a JSON representation
  8429. */
  8430. serialize(): any;
  8431. /**
  8432. * Parses the image processing from a json representation.
  8433. * @param source the JSON source to parse
  8434. * @return The parsed image processing
  8435. */
  8436. static Parse(source: any): ImageProcessingConfiguration;
  8437. private static _VIGNETTEMODE_MULTIPLY;
  8438. private static _VIGNETTEMODE_OPAQUE;
  8439. /**
  8440. * Used to apply the vignette as a mix with the pixel color.
  8441. */
  8442. static get VIGNETTEMODE_MULTIPLY(): number;
  8443. /**
  8444. * Used to apply the vignette as a replacement of the pixel color.
  8445. */
  8446. static get VIGNETTEMODE_OPAQUE(): number;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. interface ThinEngine {
  8458. /**
  8459. * Creates a new render target texture
  8460. * @param size defines the size of the texture
  8461. * @param options defines the options used to create the texture
  8462. * @returns a new render target texture stored in an InternalTexture
  8463. */
  8464. createRenderTargetTexture(size: number | {
  8465. width: number;
  8466. height: number;
  8467. layers?: number;
  8468. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8469. /**
  8470. * Creates a depth stencil texture.
  8471. * This is only available in WebGL 2 or with the depth texture extension available.
  8472. * @param size The size of face edge in the texture.
  8473. * @param options The options defining the texture.
  8474. * @returns The texture
  8475. */
  8476. createDepthStencilTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: DepthTextureCreationOptions): InternalTexture;
  8481. /** @hidden */
  8482. _createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /** Defines supported spaces */
  8491. export enum Space {
  8492. /** Local (object) space */
  8493. LOCAL = 0,
  8494. /** World space */
  8495. WORLD = 1,
  8496. /** Bone space */
  8497. BONE = 2
  8498. }
  8499. /** Defines the 3 main axes */
  8500. export class Axis {
  8501. /** X axis */
  8502. static X: Vector3;
  8503. /** Y axis */
  8504. static Y: Vector3;
  8505. /** Z axis */
  8506. static Z: Vector3;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /**
  8511. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8512. * This is the base of the follow, arc rotate cameras and Free camera
  8513. * @see http://doc.babylonjs.com/features/cameras
  8514. */
  8515. export class TargetCamera extends Camera {
  8516. private static _RigCamTransformMatrix;
  8517. private static _TargetTransformMatrix;
  8518. private static _TargetFocalPoint;
  8519. /**
  8520. * Define the current direction the camera is moving to
  8521. */
  8522. cameraDirection: Vector3;
  8523. /**
  8524. * Define the current rotation the camera is rotating to
  8525. */
  8526. cameraRotation: Vector2;
  8527. /**
  8528. * When set, the up vector of the camera will be updated by the rotation of the camera
  8529. */
  8530. updateUpVectorFromRotation: boolean;
  8531. private _tmpQuaternion;
  8532. /**
  8533. * Define the current rotation of the camera
  8534. */
  8535. rotation: Vector3;
  8536. /**
  8537. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8538. */
  8539. rotationQuaternion: Quaternion;
  8540. /**
  8541. * Define the current speed of the camera
  8542. */
  8543. speed: number;
  8544. /**
  8545. * Add constraint to the camera to prevent it to move freely in all directions and
  8546. * around all axis.
  8547. */
  8548. noRotationConstraint: boolean;
  8549. /**
  8550. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8551. * panning
  8552. */
  8553. invertRotation: boolean;
  8554. /**
  8555. * Speed multiplier for inverse camera panning
  8556. */
  8557. inverseRotationSpeed: number;
  8558. /**
  8559. * Define the current target of the camera as an object or a position.
  8560. */
  8561. lockedTarget: any;
  8562. /** @hidden */
  8563. _currentTarget: Vector3;
  8564. /** @hidden */
  8565. _initialFocalDistance: number;
  8566. /** @hidden */
  8567. _viewMatrix: Matrix;
  8568. /** @hidden */
  8569. _camMatrix: Matrix;
  8570. /** @hidden */
  8571. _cameraTransformMatrix: Matrix;
  8572. /** @hidden */
  8573. _cameraRotationMatrix: Matrix;
  8574. /** @hidden */
  8575. _referencePoint: Vector3;
  8576. /** @hidden */
  8577. _transformedReferencePoint: Vector3;
  8578. protected _globalCurrentTarget: Vector3;
  8579. protected _globalCurrentUpVector: Vector3;
  8580. /** @hidden */
  8581. _reset: () => void;
  8582. private _defaultUp;
  8583. /**
  8584. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8585. * This is the base of the follow, arc rotate cameras and Free camera
  8586. * @see http://doc.babylonjs.com/features/cameras
  8587. * @param name Defines the name of the camera in the scene
  8588. * @param position Defines the start position of the camera in the scene
  8589. * @param scene Defines the scene the camera belongs to
  8590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8591. */
  8592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8593. /**
  8594. * Gets the position in front of the camera at a given distance.
  8595. * @param distance The distance from the camera we want the position to be
  8596. * @returns the position
  8597. */
  8598. getFrontPosition(distance: number): Vector3;
  8599. /** @hidden */
  8600. _getLockedTargetPosition(): Nullable<Vector3>;
  8601. private _storedPosition;
  8602. private _storedRotation;
  8603. private _storedRotationQuaternion;
  8604. /**
  8605. * Store current camera state of the camera (fov, position, rotation, etc..)
  8606. * @returns the camera
  8607. */
  8608. storeState(): Camera;
  8609. /**
  8610. * Restored camera state. You must call storeState() first
  8611. * @returns whether it was successful or not
  8612. * @hidden
  8613. */
  8614. _restoreStateValues(): boolean;
  8615. /** @hidden */
  8616. _initCache(): void;
  8617. /** @hidden */
  8618. _updateCache(ignoreParentClass?: boolean): void;
  8619. /** @hidden */
  8620. _isSynchronizedViewMatrix(): boolean;
  8621. /** @hidden */
  8622. _computeLocalCameraSpeed(): number;
  8623. /**
  8624. * Defines the target the camera should look at.
  8625. * @param target Defines the new target as a Vector or a mesh
  8626. */
  8627. setTarget(target: Vector3): void;
  8628. /**
  8629. * Return the current target position of the camera. This value is expressed in local space.
  8630. * @returns the target position
  8631. */
  8632. getTarget(): Vector3;
  8633. /** @hidden */
  8634. _decideIfNeedsToMove(): boolean;
  8635. /** @hidden */
  8636. _updatePosition(): void;
  8637. /** @hidden */
  8638. _checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */
  8648. _getViewMatrix(): Matrix;
  8649. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8650. /**
  8651. * @hidden
  8652. */
  8653. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8654. /**
  8655. * @hidden
  8656. */
  8657. _updateRigCameras(): void;
  8658. private _getRigCamPositionAndTarget;
  8659. /**
  8660. * Gets the current object class name.
  8661. * @return the class name
  8662. */
  8663. getClassName(): string;
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Gather the list of keyboard event types as constants.
  8669. */
  8670. export class KeyboardEventTypes {
  8671. /**
  8672. * The keydown event is fired when a key becomes active (pressed).
  8673. */
  8674. static readonly KEYDOWN: number;
  8675. /**
  8676. * The keyup event is fired when a key has been released.
  8677. */
  8678. static readonly KEYUP: number;
  8679. }
  8680. /**
  8681. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8682. */
  8683. export class KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Instantiates a new keyboard info.
  8694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8695. * @param type Defines the type of event (KeyboardEventTypes)
  8696. * @param event Defines the related dom event
  8697. */
  8698. constructor(
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number,
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent);
  8707. }
  8708. /**
  8709. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8710. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8711. */
  8712. export class KeyboardInfoPre extends KeyboardInfo {
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number;
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent;
  8721. /**
  8722. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8723. */
  8724. skipOnPointerObservable: boolean;
  8725. /**
  8726. * Instantiates a new keyboard pre info.
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * @param type Defines the type of event (KeyboardEventTypes)
  8729. * @param event Defines the related dom event
  8730. */
  8731. constructor(
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number,
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent);
  8740. }
  8741. }
  8742. declare module BABYLON {
  8743. /**
  8744. * Manage the keyboard inputs to control the movement of a free camera.
  8745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8746. */
  8747. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8748. /**
  8749. * Defines the camera the input is attached to.
  8750. */
  8751. camera: FreeCamera;
  8752. /**
  8753. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8754. */
  8755. keysUp: number[];
  8756. /**
  8757. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8758. */
  8759. keysUpward: number[];
  8760. /**
  8761. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8762. */
  8763. keysDown: number[];
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8766. */
  8767. keysDownward: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8770. */
  8771. keysLeft: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8774. */
  8775. keysRight: number[];
  8776. private _keys;
  8777. private _onCanvasBlurObserver;
  8778. private _onKeyboardObserver;
  8779. private _engine;
  8780. private _scene;
  8781. /**
  8782. * Attach the input controls to a specific dom element to get the input from.
  8783. * @param element Defines the element the controls should be listened from
  8784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8785. */
  8786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8787. /**
  8788. * Detach the current controls from the specified dom element.
  8789. * @param element Defines the element to stop listening the inputs from
  8790. */
  8791. detachControl(element: Nullable<HTMLElement>): void;
  8792. /**
  8793. * Update the current camera state depending on the inputs that have been used this frame.
  8794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8795. */
  8796. checkInputs(): void;
  8797. /**
  8798. * Gets the class name of the current intput.
  8799. * @returns the class name
  8800. */
  8801. getClassName(): string;
  8802. /** @hidden */
  8803. _onLostFocus(): void;
  8804. /**
  8805. * Get the friendly name associated with the input class.
  8806. * @returns the input friendly name
  8807. */
  8808. getSimpleName(): string;
  8809. }
  8810. }
  8811. declare module BABYLON {
  8812. /**
  8813. * Interface describing all the common properties and methods a shadow light needs to implement.
  8814. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8815. * as well as binding the different shadow properties to the effects.
  8816. */
  8817. export interface IShadowLight extends Light {
  8818. /**
  8819. * The light id in the scene (used in scene.findLighById for instance)
  8820. */
  8821. id: string;
  8822. /**
  8823. * The position the shdow will be casted from.
  8824. */
  8825. position: Vector3;
  8826. /**
  8827. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8828. */
  8829. direction: Vector3;
  8830. /**
  8831. * The transformed position. Position of the light in world space taking parenting in account.
  8832. */
  8833. transformedPosition: Vector3;
  8834. /**
  8835. * The transformed direction. Direction of the light in world space taking parenting in account.
  8836. */
  8837. transformedDirection: Vector3;
  8838. /**
  8839. * The friendly name of the light in the scene.
  8840. */
  8841. name: string;
  8842. /**
  8843. * Defines the shadow projection clipping minimum z value.
  8844. */
  8845. shadowMinZ: number;
  8846. /**
  8847. * Defines the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8852. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8853. */
  8854. computeTransformedInformation(): boolean;
  8855. /**
  8856. * Gets the scene the light belongs to.
  8857. * @returns The scene
  8858. */
  8859. getScene(): Scene;
  8860. /**
  8861. * Callback defining a custom Projection Matrix Builder.
  8862. * This can be used to override the default projection matrix computation.
  8863. */
  8864. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8865. /**
  8866. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8867. * @param matrix The materix to updated with the projection information
  8868. * @param viewMatrix The transform matrix of the light
  8869. * @param renderList The list of mesh to render in the map
  8870. * @returns The current light
  8871. */
  8872. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8873. /**
  8874. * Gets the current depth scale used in ESM.
  8875. * @returns The scale
  8876. */
  8877. getDepthScale(): number;
  8878. /**
  8879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8880. * @returns true if a cube texture needs to be use
  8881. */
  8882. needCube(): boolean;
  8883. /**
  8884. * Detects if the projection matrix requires to be recomputed this frame.
  8885. * @returns true if it requires to be recomputed otherwise, false.
  8886. */
  8887. needProjectionMatrixCompute(): boolean;
  8888. /**
  8889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8890. */
  8891. forceProjectionMatrixCompute(): void;
  8892. /**
  8893. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8894. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8895. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8896. */
  8897. getShadowDirection(faceIndex?: number): Vector3;
  8898. /**
  8899. * Gets the minZ used for shadow according to both the scene and the light.
  8900. * @param activeCamera The camera we are returning the min for
  8901. * @returns the depth min z
  8902. */
  8903. getDepthMinZ(activeCamera: Camera): number;
  8904. /**
  8905. * Gets the maxZ used for shadow according to both the scene and the light.
  8906. * @param activeCamera The camera we are returning the max for
  8907. * @returns the depth max z
  8908. */
  8909. getDepthMaxZ(activeCamera: Camera): number;
  8910. }
  8911. /**
  8912. * Base implementation IShadowLight
  8913. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8914. */
  8915. export abstract class ShadowLight extends Light implements IShadowLight {
  8916. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8917. protected _position: Vector3;
  8918. protected _setPosition(value: Vector3): void;
  8919. /**
  8920. * Sets the position the shadow will be casted from. Also use as the light position for both
  8921. * point and spot lights.
  8922. */
  8923. get position(): Vector3;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. set position(value: Vector3);
  8929. protected _direction: Vector3;
  8930. protected _setDirection(value: Vector3): void;
  8931. /**
  8932. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8933. * Also use as the light direction on spot and directional lights.
  8934. */
  8935. get direction(): Vector3;
  8936. /**
  8937. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. set direction(value: Vector3);
  8941. protected _shadowMinZ: number;
  8942. /**
  8943. * Gets the shadow projection clipping minimum z value.
  8944. */
  8945. get shadowMinZ(): number;
  8946. /**
  8947. * Sets the shadow projection clipping minimum z value.
  8948. */
  8949. set shadowMinZ(value: number);
  8950. protected _shadowMaxZ: number;
  8951. /**
  8952. * Sets the shadow projection clipping maximum z value.
  8953. */
  8954. get shadowMaxZ(): number;
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. set shadowMaxZ(value: number);
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. /**
  9053. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9054. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9055. */
  9056. export class EffectFallbacks implements IEffectFallbacks {
  9057. private _defines;
  9058. private _currentRank;
  9059. private _maxRank;
  9060. private _mesh;
  9061. /**
  9062. * Removes the fallback from the bound mesh.
  9063. */
  9064. unBindMesh(): void;
  9065. /**
  9066. * Adds a fallback on the specified property.
  9067. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9068. * @param define The name of the define in the shader
  9069. */
  9070. addFallback(rank: number, define: string): void;
  9071. /**
  9072. * Sets the mesh to use CPU skinning when needing to fallback.
  9073. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9074. * @param mesh The mesh to use the fallbacks.
  9075. */
  9076. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9077. /**
  9078. * Checks to see if more fallbacks are still availible.
  9079. */
  9080. get hasMoreFallbacks(): boolean;
  9081. /**
  9082. * Removes the defines that should be removed when falling back.
  9083. * @param currentDefines defines the current define statements for the shader.
  9084. * @param effect defines the current effect we try to compile
  9085. * @returns The resulting defines with defines of the current rank removed.
  9086. */
  9087. reduce(currentDefines: string, effect: Effect): string;
  9088. }
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * "Static Class" containing the most commonly used helper while dealing with material for
  9093. * rendering purpose.
  9094. *
  9095. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9096. *
  9097. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9098. */
  9099. export class MaterialHelper {
  9100. /**
  9101. * Bind the current view position to an effect.
  9102. * @param effect The effect to be bound
  9103. * @param scene The scene the eyes position is used from
  9104. */
  9105. static BindEyePosition(effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Helps preparing the defines values about the UVs in used in the effect.
  9108. * UVs are shared as much as we can accross channels in the shaders.
  9109. * @param texture The texture we are preparing the UVs for
  9110. * @param defines The defines to update
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9114. /**
  9115. * Binds a texture matrix value to its corrsponding uniform
  9116. * @param texture The texture to bind the matrix for
  9117. * @param uniformBuffer The uniform buffer receivin the data
  9118. * @param key The channel key "diffuse", "specular"... used in the shader
  9119. */
  9120. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9121. /**
  9122. * Gets the current status of the fog (should it be enabled?)
  9123. * @param mesh defines the mesh to evaluate for fog support
  9124. * @param scene defines the hosting scene
  9125. * @returns true if fog must be enabled
  9126. */
  9127. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9128. /**
  9129. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9130. * @param mesh defines the current mesh
  9131. * @param scene defines the current scene
  9132. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9133. * @param pointsCloud defines if point cloud rendering has to be turned on
  9134. * @param fogEnabled defines if fog has to be turned on
  9135. * @param alphaTest defines if alpha testing has to be turned on
  9136. * @param defines defines the current list of defines
  9137. */
  9138. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9139. /**
  9140. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9141. * @param scene defines the current scene
  9142. * @param engine defines the current engine
  9143. * @param defines specifies the list of active defines
  9144. * @param useInstances defines if instances have to be turned on
  9145. * @param useClipPlane defines if clip plane have to be turned on
  9146. */
  9147. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9148. /**
  9149. * Prepares the defines for bones
  9150. * @param mesh The mesh containing the geometry data we will draw
  9151. * @param defines The defines to update
  9152. */
  9153. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9154. /**
  9155. * Prepares the defines for morph targets
  9156. * @param mesh The mesh containing the geometry data we will draw
  9157. * @param defines The defines to update
  9158. */
  9159. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9160. /**
  9161. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9162. * @param mesh The mesh containing the geometry data we will draw
  9163. * @param defines The defines to update
  9164. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9165. * @param useBones Precise whether bones should be used or not (override mesh info)
  9166. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9167. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9168. * @returns false if defines are considered not dirty and have not been checked
  9169. */
  9170. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9171. /**
  9172. * Prepares the defines related to multiview
  9173. * @param scene The scene we are intending to draw
  9174. * @param defines The defines to update
  9175. */
  9176. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9177. /**
  9178. * Prepares the defines related to the light information passed in parameter
  9179. * @param scene The scene we are intending to draw
  9180. * @param mesh The mesh the effect is compiling for
  9181. * @param light The light the effect is compiling for
  9182. * @param lightIndex The index of the light
  9183. * @param defines The defines to update
  9184. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9185. * @param state Defines the current state regarding what is needed (normals, etc...)
  9186. */
  9187. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9188. needNormals: boolean;
  9189. needRebuild: boolean;
  9190. shadowEnabled: boolean;
  9191. specularEnabled: boolean;
  9192. lightmapMode: boolean;
  9193. }): void;
  9194. /**
  9195. * Prepares the defines related to the light information passed in parameter
  9196. * @param scene The scene we are intending to draw
  9197. * @param mesh The mesh the effect is compiling for
  9198. * @param defines The defines to update
  9199. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9200. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9201. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9202. * @returns true if normals will be required for the rest of the effect
  9203. */
  9204. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9205. /**
  9206. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9207. * @param lightIndex defines the light index
  9208. * @param uniformsList The uniform list
  9209. * @param samplersList The sampler list
  9210. * @param projectedLightTexture defines if projected texture must be used
  9211. * @param uniformBuffersList defines an optional list of uniform buffers
  9212. */
  9213. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9214. /**
  9215. * Prepares the uniforms and samplers list to be used in the effect
  9216. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9217. * @param samplersList The sampler list
  9218. * @param defines The defines helping in the list generation
  9219. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9220. */
  9221. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9222. /**
  9223. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9224. * @param defines The defines to update while falling back
  9225. * @param fallbacks The authorized effect fallbacks
  9226. * @param maxSimultaneousLights The maximum number of lights allowed
  9227. * @param rank the current rank of the Effect
  9228. * @returns The newly affected rank
  9229. */
  9230. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9231. private static _TmpMorphInfluencers;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param influencers The number of influencers
  9237. */
  9238. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9239. /**
  9240. * Prepares the list of attributes required for morph targets according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the morph targets attributes for
  9243. * @param defines The current Defines of the effect
  9244. */
  9245. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9246. /**
  9247. * Prepares the list of attributes required for bones according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param mesh The mesh to prepare the bones attributes for
  9250. * @param defines The current Defines of the effect
  9251. * @param fallbacks The current efffect fallback strategy
  9252. */
  9253. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9254. /**
  9255. * Check and prepare the list of attributes required for instances according to the effect defines.
  9256. * @param attribs The current list of supported attribs
  9257. * @param defines The current MaterialDefines of the effect
  9258. */
  9259. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9260. /**
  9261. * Add the list of attributes required for instances to the attribs array.
  9262. * @param attribs The current list of supported attribs
  9263. */
  9264. static PushAttributesForInstances(attribs: string[]): void;
  9265. /**
  9266. * Binds the light information to the effect.
  9267. * @param light The light containing the generator
  9268. * @param effect The effect we are binding the data to
  9269. * @param lightIndex The light index in the effect used to render
  9270. */
  9271. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9272. /**
  9273. * Binds the lights information from the scene to the effect for the given mesh.
  9274. * @param light Light to bind
  9275. * @param lightIndex Light index
  9276. * @param scene The scene where the light belongs to
  9277. * @param effect The effect we are binding the data to
  9278. * @param useSpecular Defines if specular is supported
  9279. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9280. */
  9281. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param scene The scene the lights belongs to
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. * @param defines The generated defines for the effect
  9288. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9292. private static _tempFogColor;
  9293. /**
  9294. * Binds the fog information from the scene to the effect for the given mesh.
  9295. * @param scene The scene the lights belongs to
  9296. * @param mesh The mesh we are binding the information to render
  9297. * @param effect The effect we are binding the data to
  9298. * @param linearSpace Defines if the fog effect is applied in linear space
  9299. */
  9300. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9301. /**
  9302. * Binds the bones information from the mesh to the effect.
  9303. * @param mesh The mesh we are binding the information to render
  9304. * @param effect The effect we are binding the data to
  9305. */
  9306. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9307. /**
  9308. * Binds the morph targets information from the mesh to the effect.
  9309. * @param abstractMesh The mesh we are binding the information to render
  9310. * @param effect The effect we are binding the data to
  9311. */
  9312. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9313. /**
  9314. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9315. * @param defines The generated defines used in the effect
  9316. * @param effect The effect we are binding the data to
  9317. * @param scene The scene we are willing to render with logarithmic scale for
  9318. */
  9319. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9320. /**
  9321. * Binds the clip plane information from the scene to the effect.
  9322. * @param scene The scene the clip plane information are extracted from
  9323. * @param effect The effect we are binding the data to
  9324. */
  9325. static BindClipPlane(effect: Effect, scene: Scene): void;
  9326. }
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var packingFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var clipPlaneFragmentDeclaration: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var clipPlaneFragment: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var shadowMapPixelShader: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var bonesDeclaration: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var morphTargetsVertexGlobalDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var morphTargetsVertexDeclaration: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var instancesDeclaration: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var helperFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var clipPlaneVertexDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var morphTargetsVertex: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /** @hidden */
  9407. export var instancesVertex: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module BABYLON {
  9413. /** @hidden */
  9414. export var bonesVertex: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module BABYLON {
  9420. /** @hidden */
  9421. export var clipPlaneVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module BABYLON {
  9427. /** @hidden */
  9428. export var shadowMapVertexShader: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module BABYLON {
  9434. /** @hidden */
  9435. export var depthBoxBlurPixelShader: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module BABYLON {
  9441. /**
  9442. * Class representing a ray with position and direction
  9443. */
  9444. export class Ray {
  9445. /** origin point */
  9446. origin: Vector3;
  9447. /** direction */
  9448. direction: Vector3;
  9449. /** length of the ray */
  9450. length: number;
  9451. private static readonly TmpVector3;
  9452. private _tmpRay;
  9453. /**
  9454. * Creates a new ray
  9455. * @param origin origin point
  9456. * @param direction direction
  9457. * @param length length of the ray
  9458. */
  9459. constructor(
  9460. /** origin point */
  9461. origin: Vector3,
  9462. /** direction */
  9463. direction: Vector3,
  9464. /** length of the ray */
  9465. length?: number);
  9466. /**
  9467. * Checks if the ray intersects a box
  9468. * @param minimum bound of the box
  9469. * @param maximum bound of the box
  9470. * @param intersectionTreshold extra extend to be added to the box in all direction
  9471. * @returns if the box was hit
  9472. */
  9473. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9474. /**
  9475. * Checks if the ray intersects a box
  9476. * @param box the bounding box to check
  9477. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * If the ray hits a sphere
  9483. * @param sphere the bounding sphere to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9485. * @returns true if it hits the sphere
  9486. */
  9487. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a triange
  9490. * @param vertex0 triangle vertex
  9491. * @param vertex1 triangle vertex
  9492. * @param vertex2 triangle vertex
  9493. * @returns intersection information if hit
  9494. */
  9495. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9496. /**
  9497. * Checks if ray intersects a plane
  9498. * @param plane the plane to check
  9499. * @returns the distance away it was hit
  9500. */
  9501. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9502. /**
  9503. * Calculate the intercept of a ray on a given axis
  9504. * @param axis to check 'x' | 'y' | 'z'
  9505. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9506. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9507. */
  9508. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param mesh the mesh to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @returns picking info of the intersecton
  9514. */
  9515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9516. /**
  9517. * Checks if ray intersects a mesh
  9518. * @param meshes the meshes to check
  9519. * @param fastCheck if only the bounding box should checked
  9520. * @param results array to store result in
  9521. * @returns Array of picking infos
  9522. */
  9523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9524. private _comparePickingInfo;
  9525. private static smallnum;
  9526. private static rayl;
  9527. /**
  9528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9529. * @param sega the first point of the segment to test the intersection against
  9530. * @param segb the second point of the segment to test the intersection against
  9531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9533. */
  9534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9535. /**
  9536. * Update the ray from viewport position
  9537. * @param x position
  9538. * @param y y position
  9539. * @param viewportWidth viewport width
  9540. * @param viewportHeight viewport height
  9541. * @param world world matrix
  9542. * @param view view matrix
  9543. * @param projection projection matrix
  9544. * @returns this ray updated
  9545. */
  9546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Creates a ray with origin and direction of 0,0,0
  9549. * @returns the new ray
  9550. */
  9551. static Zero(): Ray;
  9552. /**
  9553. * Creates a new ray from screen space and viewport
  9554. * @param x position
  9555. * @param y y position
  9556. * @param viewportWidth viewport width
  9557. * @param viewportHeight viewport height
  9558. * @param world world matrix
  9559. * @param view view matrix
  9560. * @param projection projection matrix
  9561. * @returns new ray
  9562. */
  9563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9564. /**
  9565. * 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
  9566. * transformed to the given world matrix.
  9567. * @param origin The origin point
  9568. * @param end The end point
  9569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9570. * @returns the new ray
  9571. */
  9572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @returns the resulting new ray
  9578. */
  9579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9580. /**
  9581. * Transforms a ray by a matrix
  9582. * @param ray ray to transform
  9583. * @param matrix matrix to apply
  9584. * @param result ray to store result in
  9585. */
  9586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9587. /**
  9588. * Unproject a ray from screen space to object space
  9589. * @param sourceX defines the screen space x coordinate to use
  9590. * @param sourceY defines the screen space y coordinate to use
  9591. * @param viewportWidth defines the current width of the viewport
  9592. * @param viewportHeight defines the current height of the viewport
  9593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9594. * @param view defines the view matrix to use
  9595. * @param projection defines the projection matrix to use
  9596. */
  9597. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9598. }
  9599. /**
  9600. * Type used to define predicate used to select faces when a mesh intersection is detected
  9601. */
  9602. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9603. interface Scene {
  9604. /** @hidden */
  9605. _tempPickingRay: Nullable<Ray>;
  9606. /** @hidden */
  9607. _cachedRayForTransform: Ray;
  9608. /** @hidden */
  9609. _pickWithRayInverseMatrix: Matrix;
  9610. /** @hidden */
  9611. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9612. /** @hidden */
  9613. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9614. }
  9615. }
  9616. declare module BABYLON {
  9617. /**
  9618. * Groups all the scene component constants in one place to ease maintenance.
  9619. * @hidden
  9620. */
  9621. export class SceneComponentConstants {
  9622. static readonly NAME_EFFECTLAYER: string;
  9623. static readonly NAME_LAYER: string;
  9624. static readonly NAME_LENSFLARESYSTEM: string;
  9625. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9626. static readonly NAME_PARTICLESYSTEM: string;
  9627. static readonly NAME_GAMEPAD: string;
  9628. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9629. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9630. static readonly NAME_DEPTHRENDERER: string;
  9631. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9632. static readonly NAME_SPRITE: string;
  9633. static readonly NAME_OUTLINERENDERER: string;
  9634. static readonly NAME_PROCEDURALTEXTURE: string;
  9635. static readonly NAME_SHADOWGENERATOR: string;
  9636. static readonly NAME_OCTREE: string;
  9637. static readonly NAME_PHYSICSENGINE: string;
  9638. static readonly NAME_AUDIO: string;
  9639. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9640. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9641. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9644. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9646. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9648. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9653. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9654. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9655. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9657. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9658. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9659. static readonly STEP_AFTERRENDER_AUDIO: number;
  9660. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9664. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9665. static readonly STEP_POINTERMOVE_SPRITE: number;
  9666. static readonly STEP_POINTERDOWN_SPRITE: number;
  9667. static readonly STEP_POINTERUP_SPRITE: number;
  9668. }
  9669. /**
  9670. * This represents a scene component.
  9671. *
  9672. * This is used to decouple the dependency the scene is having on the different workloads like
  9673. * layers, post processes...
  9674. */
  9675. export interface ISceneComponent {
  9676. /**
  9677. * The name of the component. Each component must have a unique name.
  9678. */
  9679. name: string;
  9680. /**
  9681. * The scene the component belongs to.
  9682. */
  9683. scene: Scene;
  9684. /**
  9685. * Register the component to one instance of a scene.
  9686. */
  9687. register(): void;
  9688. /**
  9689. * Rebuilds the elements related to this component in case of
  9690. * context lost for instance.
  9691. */
  9692. rebuild(): void;
  9693. /**
  9694. * Disposes the component and the associated ressources.
  9695. */
  9696. dispose(): void;
  9697. }
  9698. /**
  9699. * This represents a SERIALIZABLE scene component.
  9700. *
  9701. * This extends Scene Component to add Serialization methods on top.
  9702. */
  9703. export interface ISceneSerializableComponent extends ISceneComponent {
  9704. /**
  9705. * Adds all the elements from the container to the scene
  9706. * @param container the container holding the elements
  9707. */
  9708. addFromContainer(container: AbstractScene): void;
  9709. /**
  9710. * Removes all the elements in the container from the scene
  9711. * @param container contains the elements to remove
  9712. * @param dispose if the removed element should be disposed (default: false)
  9713. */
  9714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9715. /**
  9716. * Serializes the component data to the specified json object
  9717. * @param serializationObject The object to serialize to
  9718. */
  9719. serialize(serializationObject: any): void;
  9720. }
  9721. /**
  9722. * Strong typing of a Mesh related stage step action
  9723. */
  9724. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9725. /**
  9726. * Strong typing of a Evaluate Sub Mesh related stage step action
  9727. */
  9728. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9729. /**
  9730. * Strong typing of a Active Mesh related stage step action
  9731. */
  9732. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9733. /**
  9734. * Strong typing of a Camera related stage step action
  9735. */
  9736. export type CameraStageAction = (camera: Camera) => void;
  9737. /**
  9738. * Strong typing of a Camera Frame buffer related stage step action
  9739. */
  9740. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9741. /**
  9742. * Strong typing of a Render Target related stage step action
  9743. */
  9744. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9745. /**
  9746. * Strong typing of a RenderingGroup related stage step action
  9747. */
  9748. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9749. /**
  9750. * Strong typing of a Mesh Render related stage step action
  9751. */
  9752. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9753. /**
  9754. * Strong typing of a simple stage step action
  9755. */
  9756. export type SimpleStageAction = () => void;
  9757. /**
  9758. * Strong typing of a render target action.
  9759. */
  9760. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9761. /**
  9762. * Strong typing of a pointer move action.
  9763. */
  9764. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9765. /**
  9766. * Strong typing of a pointer up/down action.
  9767. */
  9768. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9769. /**
  9770. * Representation of a stage in the scene (Basically a list of ordered steps)
  9771. * @hidden
  9772. */
  9773. export class Stage<T extends Function> extends Array<{
  9774. index: number;
  9775. component: ISceneComponent;
  9776. action: T;
  9777. }> {
  9778. /**
  9779. * Hide ctor from the rest of the world.
  9780. * @param items The items to add.
  9781. */
  9782. private constructor();
  9783. /**
  9784. * Creates a new Stage.
  9785. * @returns A new instance of a Stage
  9786. */
  9787. static Create<T extends Function>(): Stage<T>;
  9788. /**
  9789. * Registers a step in an ordered way in the targeted stage.
  9790. * @param index Defines the position to register the step in
  9791. * @param component Defines the component attached to the step
  9792. * @param action Defines the action to launch during the step
  9793. */
  9794. registerStep(index: number, component: ISceneComponent, action: T): void;
  9795. /**
  9796. * Clears all the steps from the stage.
  9797. */
  9798. clear(): void;
  9799. }
  9800. }
  9801. declare module BABYLON {
  9802. interface Scene {
  9803. /** @hidden */
  9804. _pointerOverSprite: Nullable<Sprite>;
  9805. /** @hidden */
  9806. _pickedDownSprite: Nullable<Sprite>;
  9807. /** @hidden */
  9808. _tempSpritePickingRay: Nullable<Ray>;
  9809. /**
  9810. * All of the sprite managers added to this scene
  9811. * @see http://doc.babylonjs.com/babylon101/sprites
  9812. */
  9813. spriteManagers: Array<ISpriteManager>;
  9814. /**
  9815. * An event triggered when sprites rendering is about to start
  9816. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9817. */
  9818. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9819. /**
  9820. * An event triggered when sprites rendering is done
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onAfterSpritesRenderingObservable: Observable<Scene>;
  9824. /** @hidden */
  9825. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9826. /** Launch a ray to try to pick a sprite in the scene
  9827. * @param x position on screen
  9828. * @param y position on screen
  9829. * @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
  9830. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo
  9833. */
  9834. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9835. /** Use the given ray to pick a sprite in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @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
  9838. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9839. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9840. * @returns a PickingInfo
  9841. */
  9842. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9843. /** @hidden */
  9844. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9845. /** Launch a ray to try to pick sprites in the scene
  9846. * @param x position on screen
  9847. * @param y position on screen
  9848. * @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
  9849. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo array
  9851. */
  9852. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9853. /** Use the given ray to pick sprites in the scene
  9854. * @param ray The ray (in world space) to use to pick meshes
  9855. * @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
  9856. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9857. * @returns a PickingInfo array
  9858. */
  9859. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9860. /**
  9861. * Force the sprite under the pointer
  9862. * @param sprite defines the sprite to use
  9863. */
  9864. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9865. /**
  9866. * Gets the sprite under the pointer
  9867. * @returns a Sprite or null if no sprite is under the pointer
  9868. */
  9869. getPointerOverSprite(): Nullable<Sprite>;
  9870. }
  9871. /**
  9872. * Defines the sprite scene component responsible to manage sprites
  9873. * in a given scene.
  9874. */
  9875. export class SpriteSceneComponent implements ISceneComponent {
  9876. /**
  9877. * The component name helpfull to identify the component in the list of scene components.
  9878. */
  9879. readonly name: string;
  9880. /**
  9881. * The scene the component belongs to.
  9882. */
  9883. scene: Scene;
  9884. /** @hidden */
  9885. private _spritePredicate;
  9886. /**
  9887. * Creates a new instance of the component for the given scene
  9888. * @param scene Defines the scene to register the component in
  9889. */
  9890. constructor(scene: Scene);
  9891. /**
  9892. * Registers the component in a given scene
  9893. */
  9894. register(): void;
  9895. /**
  9896. * Rebuilds the elements related to this component in case of
  9897. * context lost for instance.
  9898. */
  9899. rebuild(): void;
  9900. /**
  9901. * Disposes the component and the associated ressources.
  9902. */
  9903. dispose(): void;
  9904. private _pickSpriteButKeepRay;
  9905. private _pointerMove;
  9906. private _pointerDown;
  9907. private _pointerUp;
  9908. }
  9909. }
  9910. declare module BABYLON {
  9911. /** @hidden */
  9912. export var fogFragmentDeclaration: {
  9913. name: string;
  9914. shader: string;
  9915. };
  9916. }
  9917. declare module BABYLON {
  9918. /** @hidden */
  9919. export var fogFragment: {
  9920. name: string;
  9921. shader: string;
  9922. };
  9923. }
  9924. declare module BABYLON {
  9925. /** @hidden */
  9926. export var spritesPixelShader: {
  9927. name: string;
  9928. shader: string;
  9929. };
  9930. }
  9931. declare module BABYLON {
  9932. /** @hidden */
  9933. export var fogVertexDeclaration: {
  9934. name: string;
  9935. shader: string;
  9936. };
  9937. }
  9938. declare module BABYLON {
  9939. /** @hidden */
  9940. export var spritesVertexShader: {
  9941. name: string;
  9942. shader: string;
  9943. };
  9944. }
  9945. declare module BABYLON {
  9946. /**
  9947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9948. */
  9949. export interface ISpriteManager extends IDisposable {
  9950. /**
  9951. * Restricts the camera to viewing objects with the same layerMask.
  9952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9953. */
  9954. layerMask: number;
  9955. /**
  9956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9957. */
  9958. isPickable: boolean;
  9959. /**
  9960. * Specifies the rendering group id for this mesh (0 by default)
  9961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9962. */
  9963. renderingGroupId: number;
  9964. /**
  9965. * Defines the list of sprites managed by the manager.
  9966. */
  9967. sprites: Array<Sprite>;
  9968. /**
  9969. * Tests the intersection of a sprite with a specific ray.
  9970. * @param ray The ray we are sending to test the collision
  9971. * @param camera The camera space we are sending rays in
  9972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9974. * @returns picking info or null.
  9975. */
  9976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9977. /**
  9978. * Intersects the sprites with a ray
  9979. * @param ray defines the ray to intersect with
  9980. * @param camera defines the current active camera
  9981. * @param predicate defines a predicate used to select candidate sprites
  9982. * @returns null if no hit or a PickingInfo array
  9983. */
  9984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9985. /**
  9986. * Renders the list of sprites on screen.
  9987. */
  9988. render(): void;
  9989. }
  9990. /**
  9991. * Class used to manage multiple sprites on the same spritesheet
  9992. * @see http://doc.babylonjs.com/babylon101/sprites
  9993. */
  9994. export class SpriteManager implements ISpriteManager {
  9995. /** defines the manager's name */
  9996. name: string;
  9997. /** Gets the list of sprites */
  9998. sprites: Sprite[];
  9999. /** Gets or sets the rendering group id (0 by default) */
  10000. renderingGroupId: number;
  10001. /** Gets or sets camera layer mask */
  10002. layerMask: number;
  10003. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10004. fogEnabled: boolean;
  10005. /** Gets or sets a boolean indicating if the sprites are pickable */
  10006. isPickable: boolean;
  10007. /** Defines the default width of a cell in the spritesheet */
  10008. cellWidth: number;
  10009. /** Defines the default height of a cell in the spritesheet */
  10010. cellHeight: number;
  10011. /** Associative array from JSON sprite data file */
  10012. private _cellData;
  10013. /** Array of sprite names from JSON sprite data file */
  10014. private _spriteMap;
  10015. /** True when packed cell data from JSON file is ready*/
  10016. private _packedAndReady;
  10017. /**
  10018. * An event triggered when the manager is disposed.
  10019. */
  10020. onDisposeObservable: Observable<SpriteManager>;
  10021. private _onDisposeObserver;
  10022. /**
  10023. * Callback called when the manager is disposed
  10024. */
  10025. set onDispose(callback: () => void);
  10026. private _capacity;
  10027. private _fromPacked;
  10028. private _spriteTexture;
  10029. private _epsilon;
  10030. private _scene;
  10031. private _vertexData;
  10032. private _buffer;
  10033. private _vertexBuffers;
  10034. private _indexBuffer;
  10035. private _effectBase;
  10036. private _effectFog;
  10037. /**
  10038. * Gets or sets the spritesheet texture
  10039. */
  10040. get texture(): Texture;
  10041. set texture(value: Texture);
  10042. private _blendMode;
  10043. /**
  10044. * Blend mode use to render the particle, it can be any of
  10045. * the static Constants.ALPHA_x properties provided in this class.
  10046. * Default value is Constants.ALPHA_COMBINE
  10047. */
  10048. get blendMode(): number;
  10049. set blendMode(blendMode: number);
  10050. /** Disables writing to the depth buffer when rendering the sprites.
  10051. * It can be handy to disable depth writing when using textures without alpha channel
  10052. * and setting some specific blend modes.
  10053. */
  10054. disableDepthWrite: boolean;
  10055. /**
  10056. * Creates a new sprite manager
  10057. * @param name defines the manager's name
  10058. * @param imgUrl defines the sprite sheet url
  10059. * @param capacity defines the maximum allowed number of sprites
  10060. * @param cellSize defines the size of a sprite cell
  10061. * @param scene defines the hosting scene
  10062. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10063. * @param samplingMode defines the smapling mode to use with spritesheet
  10064. * @param fromPacked set to false; do not alter
  10065. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10066. */
  10067. constructor(
  10068. /** defines the manager's name */
  10069. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10070. private _makePacked;
  10071. private _appendSpriteVertex;
  10072. /**
  10073. * Intersects the sprites with a ray
  10074. * @param ray defines the ray to intersect with
  10075. * @param camera defines the current active camera
  10076. * @param predicate defines a predicate used to select candidate sprites
  10077. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10078. * @returns null if no hit or a PickingInfo
  10079. */
  10080. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10081. /**
  10082. * Intersects the sprites with a ray
  10083. * @param ray defines the ray to intersect with
  10084. * @param camera defines the current active camera
  10085. * @param predicate defines a predicate used to select candidate sprites
  10086. * @returns null if no hit or a PickingInfo array
  10087. */
  10088. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10089. /**
  10090. * Render all child sprites
  10091. */
  10092. render(): void;
  10093. /**
  10094. * Release associated resources
  10095. */
  10096. dispose(): void;
  10097. }
  10098. }
  10099. declare module BABYLON {
  10100. /** Interface used by value gradients (color, factor, ...) */
  10101. export interface IValueGradient {
  10102. /**
  10103. * Gets or sets the gradient value (between 0 and 1)
  10104. */
  10105. gradient: number;
  10106. }
  10107. /** Class used to store color4 gradient */
  10108. export class ColorGradient implements IValueGradient {
  10109. /**
  10110. * Gets or sets the gradient value (between 0 and 1)
  10111. */
  10112. gradient: number;
  10113. /**
  10114. * Gets or sets first associated color
  10115. */
  10116. color1: Color4;
  10117. /**
  10118. * Gets or sets second associated color
  10119. */
  10120. color2?: Color4;
  10121. /**
  10122. * Will get a color picked randomly between color1 and color2.
  10123. * If color2 is undefined then color1 will be used
  10124. * @param result defines the target Color4 to store the result in
  10125. */
  10126. getColorToRef(result: Color4): void;
  10127. }
  10128. /** Class used to store color 3 gradient */
  10129. export class Color3Gradient implements IValueGradient {
  10130. /**
  10131. * Gets or sets the gradient value (between 0 and 1)
  10132. */
  10133. gradient: number;
  10134. /**
  10135. * Gets or sets the associated color
  10136. */
  10137. color: Color3;
  10138. }
  10139. /** Class used to store factor gradient */
  10140. export class FactorGradient implements IValueGradient {
  10141. /**
  10142. * Gets or sets the gradient value (between 0 and 1)
  10143. */
  10144. gradient: number;
  10145. /**
  10146. * Gets or sets first associated factor
  10147. */
  10148. factor1: number;
  10149. /**
  10150. * Gets or sets second associated factor
  10151. */
  10152. factor2?: number;
  10153. /**
  10154. * Will get a number picked randomly between factor1 and factor2.
  10155. * If factor2 is undefined then factor1 will be used
  10156. * @returns the picked number
  10157. */
  10158. getFactor(): number;
  10159. }
  10160. /**
  10161. * Helper used to simplify some generic gradient tasks
  10162. */
  10163. export class GradientHelper {
  10164. /**
  10165. * Gets the current gradient from an array of IValueGradient
  10166. * @param ratio defines the current ratio to get
  10167. * @param gradients defines the array of IValueGradient
  10168. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10169. */
  10170. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10171. }
  10172. }
  10173. declare module BABYLON {
  10174. /**
  10175. * Interface for the size containing width and height
  10176. */
  10177. export interface ISize {
  10178. /**
  10179. * Width
  10180. */
  10181. width: number;
  10182. /**
  10183. * Heighht
  10184. */
  10185. height: number;
  10186. }
  10187. /**
  10188. * Size containing widht and height
  10189. */
  10190. export class Size implements ISize {
  10191. /**
  10192. * Width
  10193. */
  10194. width: number;
  10195. /**
  10196. * Height
  10197. */
  10198. height: number;
  10199. /**
  10200. * Creates a Size object from the given width and height (floats).
  10201. * @param width width of the new size
  10202. * @param height height of the new size
  10203. */
  10204. constructor(width: number, height: number);
  10205. /**
  10206. * Returns a string with the Size width and height
  10207. * @returns a string with the Size width and height
  10208. */
  10209. toString(): string;
  10210. /**
  10211. * "Size"
  10212. * @returns the string "Size"
  10213. */
  10214. getClassName(): string;
  10215. /**
  10216. * Returns the Size hash code.
  10217. * @returns a hash code for a unique width and height
  10218. */
  10219. getHashCode(): number;
  10220. /**
  10221. * Updates the current size from the given one.
  10222. * @param src the given size
  10223. */
  10224. copyFrom(src: Size): void;
  10225. /**
  10226. * Updates in place the current Size from the given floats.
  10227. * @param width width of the new size
  10228. * @param height height of the new size
  10229. * @returns the updated Size.
  10230. */
  10231. copyFromFloats(width: number, height: number): Size;
  10232. /**
  10233. * Updates in place the current Size from the given floats.
  10234. * @param width width to set
  10235. * @param height height to set
  10236. * @returns the updated Size.
  10237. */
  10238. set(width: number, height: number): Size;
  10239. /**
  10240. * Multiplies the width and height by numbers
  10241. * @param w factor to multiple the width by
  10242. * @param h factor to multiple the height by
  10243. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10244. */
  10245. multiplyByFloats(w: number, h: number): Size;
  10246. /**
  10247. * Clones the size
  10248. * @returns a new Size copied from the given one.
  10249. */
  10250. clone(): Size;
  10251. /**
  10252. * True if the current Size and the given one width and height are strictly equal.
  10253. * @param other the other size to compare against
  10254. * @returns True if the current Size and the given one width and height are strictly equal.
  10255. */
  10256. equals(other: Size): boolean;
  10257. /**
  10258. * The surface of the Size : width * height (float).
  10259. */
  10260. get surface(): number;
  10261. /**
  10262. * Create a new size of zero
  10263. * @returns a new Size set to (0.0, 0.0)
  10264. */
  10265. static Zero(): Size;
  10266. /**
  10267. * Sums the width and height of two sizes
  10268. * @param otherSize size to add to this size
  10269. * @returns a new Size set as the addition result of the current Size and the given one.
  10270. */
  10271. add(otherSize: Size): Size;
  10272. /**
  10273. * Subtracts the width and height of two
  10274. * @param otherSize size to subtract to this size
  10275. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10276. */
  10277. subtract(otherSize: Size): Size;
  10278. /**
  10279. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10280. * @param start starting size to lerp between
  10281. * @param end end size to lerp between
  10282. * @param amount amount to lerp between the start and end values
  10283. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10284. */
  10285. static Lerp(start: Size, end: Size, amount: number): Size;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. interface ThinEngine {
  10290. /**
  10291. * Creates a dynamic texture
  10292. * @param width defines the width of the texture
  10293. * @param height defines the height of the texture
  10294. * @param generateMipMaps defines if the engine should generate the mip levels
  10295. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10296. * @returns the dynamic texture inside an InternalTexture
  10297. */
  10298. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10299. /**
  10300. * Update the content of a dynamic texture
  10301. * @param texture defines the texture to update
  10302. * @param canvas defines the canvas containing the source
  10303. * @param invertY defines if data must be stored with Y axis inverted
  10304. * @param premulAlpha defines if alpha is stored as premultiplied
  10305. * @param format defines the format of the data
  10306. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10307. */
  10308. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Helper class used to generate a canvas to manipulate images
  10314. */
  10315. export class CanvasGenerator {
  10316. /**
  10317. * Create a new canvas (or offscreen canvas depending on the context)
  10318. * @param width defines the expected width
  10319. * @param height defines the expected height
  10320. * @return a new canvas or offscreen canvas
  10321. */
  10322. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10323. }
  10324. }
  10325. declare module BABYLON {
  10326. /**
  10327. * A class extending Texture allowing drawing on a texture
  10328. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10329. */
  10330. export class DynamicTexture extends Texture {
  10331. private _generateMipMaps;
  10332. private _canvas;
  10333. private _context;
  10334. private _engine;
  10335. /**
  10336. * Creates a DynamicTexture
  10337. * @param name defines the name of the texture
  10338. * @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
  10339. * @param scene defines the scene where you want the texture
  10340. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10341. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10342. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10343. */
  10344. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10345. /**
  10346. * Get the current class name of the texture useful for serialization or dynamic coding.
  10347. * @returns "DynamicTexture"
  10348. */
  10349. getClassName(): string;
  10350. /**
  10351. * Gets the current state of canRescale
  10352. */
  10353. get canRescale(): boolean;
  10354. private _recreate;
  10355. /**
  10356. * Scales the texture
  10357. * @param ratio the scale factor to apply to both width and height
  10358. */
  10359. scale(ratio: number): void;
  10360. /**
  10361. * Resizes the texture
  10362. * @param width the new width
  10363. * @param height the new height
  10364. */
  10365. scaleTo(width: number, height: number): void;
  10366. /**
  10367. * Gets the context of the canvas used by the texture
  10368. * @returns the canvas context of the dynamic texture
  10369. */
  10370. getContext(): CanvasRenderingContext2D;
  10371. /**
  10372. * Clears the texture
  10373. */
  10374. clear(): void;
  10375. /**
  10376. * Updates the texture
  10377. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10378. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10379. */
  10380. update(invertY?: boolean, premulAlpha?: boolean): void;
  10381. /**
  10382. * Draws text onto the texture
  10383. * @param text defines the text to be drawn
  10384. * @param x defines the placement of the text from the left
  10385. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10386. * @param font defines the font to be used with font-style, font-size, font-name
  10387. * @param color defines the color used for the text
  10388. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10389. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10390. * @param update defines whether texture is immediately update (default is true)
  10391. */
  10392. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10393. /**
  10394. * Clones the texture
  10395. * @returns the clone of the texture.
  10396. */
  10397. clone(): DynamicTexture;
  10398. /**
  10399. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10400. * @returns a serialized dynamic texture object
  10401. */
  10402. serialize(): any;
  10403. /** @hidden */
  10404. _rebuild(): void;
  10405. }
  10406. }
  10407. declare module BABYLON {
  10408. interface Engine {
  10409. /**
  10410. * Creates a raw texture
  10411. * @param data defines the data to store in the texture
  10412. * @param width defines the width of the texture
  10413. * @param height defines the height of the texture
  10414. * @param format defines the format of the data
  10415. * @param generateMipMaps defines if the engine should generate the mip levels
  10416. * @param invertY defines if data must be stored with Y axis inverted
  10417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10418. * @param compression defines the compression used (null by default)
  10419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10420. * @returns the raw texture inside an InternalTexture
  10421. */
  10422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10423. /**
  10424. * Update a raw texture
  10425. * @param texture defines the texture to update
  10426. * @param data defines the data to store in the texture
  10427. * @param format defines the format of the data
  10428. * @param invertY defines if data must be stored with Y axis inverted
  10429. */
  10430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10431. /**
  10432. * Update a raw texture
  10433. * @param texture defines the texture to update
  10434. * @param data defines the data to store in the texture
  10435. * @param format defines the format of the data
  10436. * @param invertY defines if data must be stored with Y axis inverted
  10437. * @param compression defines the compression used (null by default)
  10438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10439. */
  10440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10441. /**
  10442. * Creates a new raw cube texture
  10443. * @param data defines the array of data to use to create each face
  10444. * @param size defines the size of the textures
  10445. * @param format defines the format of the data
  10446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10447. * @param generateMipMaps defines if the engine should generate the mip levels
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10450. * @param compression defines the compression used (null by default)
  10451. * @returns the cube texture as an InternalTexture
  10452. */
  10453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10454. /**
  10455. * Update a raw cube texture
  10456. * @param texture defines the texture to udpdate
  10457. * @param data defines the data to store
  10458. * @param format defines the data format
  10459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. */
  10462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10463. /**
  10464. * Update a raw cube texture
  10465. * @param texture defines the texture to udpdate
  10466. * @param data defines the data to store
  10467. * @param format defines the data format
  10468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param compression defines the compression used (null by default)
  10471. */
  10472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10473. /**
  10474. * Update a raw cube texture
  10475. * @param texture defines the texture to udpdate
  10476. * @param data defines the data to store
  10477. * @param format defines the data format
  10478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10479. * @param invertY defines if data must be stored with Y axis inverted
  10480. * @param compression defines the compression used (null by default)
  10481. * @param level defines which level of the texture to update
  10482. */
  10483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10484. /**
  10485. * Creates a new raw cube texture from a specified url
  10486. * @param url defines the url where the data is located
  10487. * @param scene defines the current scene
  10488. * @param size defines the size of the textures
  10489. * @param format defines the format of the data
  10490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10491. * @param noMipmap defines if the engine should avoid generating the mip levels
  10492. * @param callback defines a callback used to extract texture data from loaded data
  10493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10494. * @param onLoad defines a callback called when texture is loaded
  10495. * @param onError defines a callback called if there is an error
  10496. * @returns the cube texture as an InternalTexture
  10497. */
  10498. 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;
  10499. /**
  10500. * Creates a new raw cube texture from a specified url
  10501. * @param url defines the url where the data is located
  10502. * @param scene defines the current scene
  10503. * @param size defines the size of the textures
  10504. * @param format defines the format of the data
  10505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10506. * @param noMipmap defines if the engine should avoid generating the mip levels
  10507. * @param callback defines a callback used to extract texture data from loaded data
  10508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10509. * @param onLoad defines a callback called when texture is loaded
  10510. * @param onError defines a callback called if there is an error
  10511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10512. * @param invertY defines if data must be stored with Y axis inverted
  10513. * @returns the cube texture as an InternalTexture
  10514. */
  10515. 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;
  10516. /**
  10517. * Creates a new raw 3D texture
  10518. * @param data defines the data used to create the texture
  10519. * @param width defines the width of the texture
  10520. * @param height defines the height of the texture
  10521. * @param depth defines the depth of the texture
  10522. * @param format defines the format of the texture
  10523. * @param generateMipMaps defines if the engine must generate mip levels
  10524. * @param invertY defines if data must be stored with Y axis inverted
  10525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10526. * @param compression defines the compressed used (can be null)
  10527. * @param textureType defines the compressed used (can be null)
  10528. * @returns a new raw 3D texture (stored in an InternalTexture)
  10529. */
  10530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10531. /**
  10532. * Update a raw 3D texture
  10533. * @param texture defines the texture to update
  10534. * @param data defines the data to store
  10535. * @param format defines the data format
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. */
  10538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10539. /**
  10540. * Update a raw 3D texture
  10541. * @param texture defines the texture to update
  10542. * @param data defines the data to store
  10543. * @param format defines the data format
  10544. * @param invertY defines if data must be stored with Y axis inverted
  10545. * @param compression defines the used compression (can be null)
  10546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10547. */
  10548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10549. /**
  10550. * Creates a new raw 2D array texture
  10551. * @param data defines the data used to create the texture
  10552. * @param width defines the width of the texture
  10553. * @param height defines the height of the texture
  10554. * @param depth defines the number of layers of the texture
  10555. * @param format defines the format of the texture
  10556. * @param generateMipMaps defines if the engine must generate mip levels
  10557. * @param invertY defines if data must be stored with Y axis inverted
  10558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10559. * @param compression defines the compressed used (can be null)
  10560. * @param textureType defines the compressed used (can be null)
  10561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10562. */
  10563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10564. /**
  10565. * Update a raw 2D array texture
  10566. * @param texture defines the texture to update
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. */
  10571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10572. /**
  10573. * Update a raw 2D array texture
  10574. * @param texture defines the texture to update
  10575. * @param data defines the data to store
  10576. * @param format defines the data format
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param compression defines the used compression (can be null)
  10579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10580. */
  10581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10582. }
  10583. }
  10584. declare module BABYLON {
  10585. /**
  10586. * Raw texture can help creating a texture directly from an array of data.
  10587. * This can be super useful if you either get the data from an uncompressed source or
  10588. * if you wish to create your texture pixel by pixel.
  10589. */
  10590. export class RawTexture extends Texture {
  10591. /**
  10592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10593. */
  10594. format: number;
  10595. private _engine;
  10596. /**
  10597. * Instantiates a new RawTexture.
  10598. * Raw texture can help creating a texture directly from an array of data.
  10599. * This can be super useful if you either get the data from an uncompressed source or
  10600. * if you wish to create your texture pixel by pixel.
  10601. * @param data define the array of data to use to create the texture
  10602. * @param width define the width of the texture
  10603. * @param height define the height of the texture
  10604. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10605. * @param scene define the scene the texture belongs to
  10606. * @param generateMipMaps define whether mip maps should be generated or not
  10607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10610. */
  10611. constructor(data: ArrayBufferView, width: number, height: number,
  10612. /**
  10613. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10614. */
  10615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10616. /**
  10617. * Updates the texture underlying data.
  10618. * @param data Define the new data of the texture
  10619. */
  10620. update(data: ArrayBufferView): void;
  10621. /**
  10622. * Creates a luminance texture from some data.
  10623. * @param data Define the texture data
  10624. * @param width Define the width of the texture
  10625. * @param height Define the height of the texture
  10626. * @param scene Define the scene the texture belongs to
  10627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10630. * @returns the luminance texture
  10631. */
  10632. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10633. /**
  10634. * Creates a luminance alpha texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @returns the luminance alpha texture
  10643. */
  10644. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10645. /**
  10646. * Creates an alpha texture from some data.
  10647. * @param data Define the texture data
  10648. * @param width Define the width of the texture
  10649. * @param height Define the height of the texture
  10650. * @param scene Define the scene the texture belongs to
  10651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10654. * @returns the alpha texture
  10655. */
  10656. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10657. /**
  10658. * Creates a RGB texture from some data.
  10659. * @param data Define the texture data
  10660. * @param width Define the width of the texture
  10661. * @param height Define the height of the texture
  10662. * @param scene Define the scene the texture belongs to
  10663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. * @returns the RGB alpha texture
  10668. */
  10669. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10670. /**
  10671. * Creates a RGBA texture from some data.
  10672. * @param data Define the texture data
  10673. * @param width Define the width of the texture
  10674. * @param height Define the height of the texture
  10675. * @param scene Define the scene the texture belongs to
  10676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10679. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10680. * @returns the RGBA texture
  10681. */
  10682. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10683. /**
  10684. * Creates a R texture from some data.
  10685. * @param data Define the texture data
  10686. * @param width Define the width of the texture
  10687. * @param height Define the height of the texture
  10688. * @param scene Define the scene the texture belongs to
  10689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10693. * @returns the R texture
  10694. */
  10695. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10696. }
  10697. }
  10698. declare module BABYLON {
  10699. interface AbstractScene {
  10700. /**
  10701. * The list of procedural textures added to the scene
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10703. */
  10704. proceduralTextures: Array<ProceduralTexture>;
  10705. }
  10706. /**
  10707. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10708. * in a given scene.
  10709. */
  10710. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10711. /**
  10712. * The component name helpfull to identify the component in the list of scene components.
  10713. */
  10714. readonly name: string;
  10715. /**
  10716. * The scene the component belongs to.
  10717. */
  10718. scene: Scene;
  10719. /**
  10720. * Creates a new instance of the component for the given scene
  10721. * @param scene Defines the scene to register the component in
  10722. */
  10723. constructor(scene: Scene);
  10724. /**
  10725. * Registers the component in a given scene
  10726. */
  10727. register(): void;
  10728. /**
  10729. * Rebuilds the elements related to this component in case of
  10730. * context lost for instance.
  10731. */
  10732. rebuild(): void;
  10733. /**
  10734. * Disposes the component and the associated ressources.
  10735. */
  10736. dispose(): void;
  10737. private _beforeClear;
  10738. }
  10739. }
  10740. declare module BABYLON {
  10741. interface ThinEngine {
  10742. /**
  10743. * Creates a new render target cube texture
  10744. * @param size defines the size of the texture
  10745. * @param options defines the options used to create the texture
  10746. * @returns a new render target cube texture stored in an InternalTexture
  10747. */
  10748. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. /** @hidden */
  10753. export var proceduralVertexShader: {
  10754. name: string;
  10755. shader: string;
  10756. };
  10757. }
  10758. declare module BABYLON {
  10759. /**
  10760. * 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.
  10761. * This is the base class of any Procedural texture and contains most of the shareable code.
  10762. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10763. */
  10764. export class ProceduralTexture extends Texture {
  10765. isCube: boolean;
  10766. /**
  10767. * Define if the texture is enabled or not (disabled texture will not render)
  10768. */
  10769. isEnabled: boolean;
  10770. /**
  10771. * Define if the texture must be cleared before rendering (default is true)
  10772. */
  10773. autoClear: boolean;
  10774. /**
  10775. * Callback called when the texture is generated
  10776. */
  10777. onGenerated: () => void;
  10778. /**
  10779. * Event raised when the texture is generated
  10780. */
  10781. onGeneratedObservable: Observable<ProceduralTexture>;
  10782. /** @hidden */
  10783. _generateMipMaps: boolean;
  10784. /** @hidden **/
  10785. _effect: Effect;
  10786. /** @hidden */
  10787. _textures: {
  10788. [key: string]: Texture;
  10789. };
  10790. private _size;
  10791. private _currentRefreshId;
  10792. private _frameId;
  10793. private _refreshRate;
  10794. private _vertexBuffers;
  10795. private _indexBuffer;
  10796. private _uniforms;
  10797. private _samplers;
  10798. private _fragment;
  10799. private _floats;
  10800. private _ints;
  10801. private _floatsArrays;
  10802. private _colors3;
  10803. private _colors4;
  10804. private _vectors2;
  10805. private _vectors3;
  10806. private _matrices;
  10807. private _fallbackTexture;
  10808. private _fallbackTextureUsed;
  10809. private _engine;
  10810. private _cachedDefines;
  10811. private _contentUpdateId;
  10812. private _contentData;
  10813. /**
  10814. * Instantiates a new procedural texture.
  10815. * 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.
  10816. * This is the base class of any Procedural texture and contains most of the shareable code.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10818. * @param name Define the name of the texture
  10819. * @param size Define the size of the texture to create
  10820. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10821. * @param scene Define the scene the texture belongs to
  10822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10823. * @param generateMipMaps Define if the texture should creates mip maps or not
  10824. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10825. */
  10826. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10827. /**
  10828. * The effect that is created when initializing the post process.
  10829. * @returns The created effect corresponding the the postprocess.
  10830. */
  10831. getEffect(): Effect;
  10832. /**
  10833. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10834. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10835. */
  10836. getContent(): Nullable<ArrayBufferView>;
  10837. private _createIndexBuffer;
  10838. /** @hidden */
  10839. _rebuild(): void;
  10840. /**
  10841. * Resets the texture in order to recreate its associated resources.
  10842. * This can be called in case of context loss
  10843. */
  10844. reset(): void;
  10845. protected _getDefines(): string;
  10846. /**
  10847. * Is the texture ready to be used ? (rendered at least once)
  10848. * @returns true if ready, otherwise, false.
  10849. */
  10850. isReady(): boolean;
  10851. /**
  10852. * Resets the refresh counter of the texture and start bak from scratch.
  10853. * Could be useful to regenerate the texture if it is setup to render only once.
  10854. */
  10855. resetRefreshCounter(): void;
  10856. /**
  10857. * Set the fragment shader to use in order to render the texture.
  10858. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10859. */
  10860. setFragment(fragment: any): void;
  10861. /**
  10862. * Define the refresh rate of the texture or the rendering frequency.
  10863. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10864. */
  10865. get refreshRate(): number;
  10866. set refreshRate(value: number);
  10867. /** @hidden */
  10868. _shouldRender(): boolean;
  10869. /**
  10870. * Get the size the texture is rendering at.
  10871. * @returns the size (texture is always squared)
  10872. */
  10873. getRenderSize(): number;
  10874. /**
  10875. * Resize the texture to new value.
  10876. * @param size Define the new size the texture should have
  10877. * @param generateMipMaps Define whether the new texture should create mip maps
  10878. */
  10879. resize(size: number, generateMipMaps: boolean): void;
  10880. private _checkUniform;
  10881. /**
  10882. * Set a texture in the shader program used to render.
  10883. * @param name Define the name of the uniform samplers as defined in the shader
  10884. * @param texture Define the texture to bind to this sampler
  10885. * @return the texture itself allowing "fluent" like uniform updates
  10886. */
  10887. setTexture(name: string, texture: Texture): ProceduralTexture;
  10888. /**
  10889. * Set a float in the shader.
  10890. * @param name Define the name of the uniform as defined in the shader
  10891. * @param value Define the value to give to the uniform
  10892. * @return the texture itself allowing "fluent" like uniform updates
  10893. */
  10894. setFloat(name: string, value: number): ProceduralTexture;
  10895. /**
  10896. * Set a int in the shader.
  10897. * @param name Define the name of the uniform as defined in the shader
  10898. * @param value Define the value to give to the uniform
  10899. * @return the texture itself allowing "fluent" like uniform updates
  10900. */
  10901. setInt(name: string, value: number): ProceduralTexture;
  10902. /**
  10903. * Set an array of floats in the shader.
  10904. * @param name Define the name of the uniform as defined in the shader
  10905. * @param value Define the value to give to the uniform
  10906. * @return the texture itself allowing "fluent" like uniform updates
  10907. */
  10908. setFloats(name: string, value: number[]): ProceduralTexture;
  10909. /**
  10910. * Set a vec3 in the shader from a Color3.
  10911. * @param name Define the name of the uniform as defined in the shader
  10912. * @param value Define the value to give to the uniform
  10913. * @return the texture itself allowing "fluent" like uniform updates
  10914. */
  10915. setColor3(name: string, value: Color3): ProceduralTexture;
  10916. /**
  10917. * Set a vec4 in the shader from a Color4.
  10918. * @param name Define the name of the uniform as defined in the shader
  10919. * @param value Define the value to give to the uniform
  10920. * @return the texture itself allowing "fluent" like uniform updates
  10921. */
  10922. setColor4(name: string, value: Color4): ProceduralTexture;
  10923. /**
  10924. * Set a vec2 in the shader from a Vector2.
  10925. * @param name Define the name of the uniform as defined in the shader
  10926. * @param value Define the value to give to the uniform
  10927. * @return the texture itself allowing "fluent" like uniform updates
  10928. */
  10929. setVector2(name: string, value: Vector2): ProceduralTexture;
  10930. /**
  10931. * Set a vec3 in the shader from a Vector3.
  10932. * @param name Define the name of the uniform as defined in the shader
  10933. * @param value Define the value to give to the uniform
  10934. * @return the texture itself allowing "fluent" like uniform updates
  10935. */
  10936. setVector3(name: string, value: Vector3): ProceduralTexture;
  10937. /**
  10938. * Set a mat4 in the shader from a MAtrix.
  10939. * @param name Define the name of the uniform as defined in the shader
  10940. * @param value Define the value to give to the uniform
  10941. * @return the texture itself allowing "fluent" like uniform updates
  10942. */
  10943. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10944. /**
  10945. * Render the texture to its associated render target.
  10946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10947. */
  10948. render(useCameraPostProcess?: boolean): void;
  10949. /**
  10950. * Clone the texture.
  10951. * @returns the cloned texture
  10952. */
  10953. clone(): ProceduralTexture;
  10954. /**
  10955. * Dispose the texture and release its asoociated resources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. }
  10960. declare module BABYLON {
  10961. /**
  10962. * This represents the base class for particle system in Babylon.
  10963. * 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.
  10964. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10965. * @example https://doc.babylonjs.com/babylon101/particles
  10966. */
  10967. export class BaseParticleSystem {
  10968. /**
  10969. * Source color is added to the destination color without alpha affecting the result
  10970. */
  10971. static BLENDMODE_ONEONE: number;
  10972. /**
  10973. * Blend current color and particle color using particle’s alpha
  10974. */
  10975. static BLENDMODE_STANDARD: number;
  10976. /**
  10977. * Add current color and particle color multiplied by particle’s alpha
  10978. */
  10979. static BLENDMODE_ADD: number;
  10980. /**
  10981. * Multiply current color with particle color
  10982. */
  10983. static BLENDMODE_MULTIPLY: number;
  10984. /**
  10985. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10986. */
  10987. static BLENDMODE_MULTIPLYADD: number;
  10988. /**
  10989. * List of animations used by the particle system.
  10990. */
  10991. animations: Animation[];
  10992. /**
  10993. * The id of the Particle system.
  10994. */
  10995. id: string;
  10996. /**
  10997. * The friendly name of the Particle system.
  10998. */
  10999. name: string;
  11000. /**
  11001. * The rendering group used by the Particle system to chose when to render.
  11002. */
  11003. renderingGroupId: number;
  11004. /**
  11005. * The emitter represents the Mesh or position we are attaching the particle system to.
  11006. */
  11007. emitter: Nullable<AbstractMesh | Vector3>;
  11008. /**
  11009. * The maximum number of particles to emit per frame
  11010. */
  11011. emitRate: number;
  11012. /**
  11013. * If you want to launch only a few particles at once, that can be done, as well.
  11014. */
  11015. manualEmitCount: number;
  11016. /**
  11017. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11018. */
  11019. updateSpeed: number;
  11020. /**
  11021. * The amount of time the particle system is running (depends of the overall update speed).
  11022. */
  11023. targetStopDuration: number;
  11024. /**
  11025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11026. */
  11027. disposeOnStop: boolean;
  11028. /**
  11029. * Minimum power of emitting particles.
  11030. */
  11031. minEmitPower: number;
  11032. /**
  11033. * Maximum power of emitting particles.
  11034. */
  11035. maxEmitPower: number;
  11036. /**
  11037. * Minimum life time of emitting particles.
  11038. */
  11039. minLifeTime: number;
  11040. /**
  11041. * Maximum life time of emitting particles.
  11042. */
  11043. maxLifeTime: number;
  11044. /**
  11045. * Minimum Size of emitting particles.
  11046. */
  11047. minSize: number;
  11048. /**
  11049. * Maximum Size of emitting particles.
  11050. */
  11051. maxSize: number;
  11052. /**
  11053. * Minimum scale of emitting particles on X axis.
  11054. */
  11055. minScaleX: number;
  11056. /**
  11057. * Maximum scale of emitting particles on X axis.
  11058. */
  11059. maxScaleX: number;
  11060. /**
  11061. * Minimum scale of emitting particles on Y axis.
  11062. */
  11063. minScaleY: number;
  11064. /**
  11065. * Maximum scale of emitting particles on Y axis.
  11066. */
  11067. maxScaleY: number;
  11068. /**
  11069. * Gets or sets the minimal initial rotation in radians.
  11070. */
  11071. minInitialRotation: number;
  11072. /**
  11073. * Gets or sets the maximal initial rotation in radians.
  11074. */
  11075. maxInitialRotation: number;
  11076. /**
  11077. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11078. */
  11079. minAngularSpeed: number;
  11080. /**
  11081. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11082. */
  11083. maxAngularSpeed: number;
  11084. /**
  11085. * The texture used to render each particle. (this can be a spritesheet)
  11086. */
  11087. particleTexture: Nullable<Texture>;
  11088. /**
  11089. * The layer mask we are rendering the particles through.
  11090. */
  11091. layerMask: number;
  11092. /**
  11093. * This can help using your own shader to render the particle system.
  11094. * The according effect will be created
  11095. */
  11096. customShader: any;
  11097. /**
  11098. * By default particle system starts as soon as they are created. This prevents the
  11099. * automatic start to happen and let you decide when to start emitting particles.
  11100. */
  11101. preventAutoStart: boolean;
  11102. private _noiseTexture;
  11103. /**
  11104. * Gets or sets a texture used to add random noise to particle positions
  11105. */
  11106. get noiseTexture(): Nullable<ProceduralTexture>;
  11107. set noiseTexture(value: Nullable<ProceduralTexture>);
  11108. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11109. noiseStrength: Vector3;
  11110. /**
  11111. * Callback triggered when the particle animation is ending.
  11112. */
  11113. onAnimationEnd: Nullable<() => void>;
  11114. /**
  11115. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11116. */
  11117. blendMode: number;
  11118. /**
  11119. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11120. * to override the particles.
  11121. */
  11122. forceDepthWrite: boolean;
  11123. /** 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 */
  11124. preWarmCycles: number;
  11125. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11126. preWarmStepOffset: number;
  11127. /**
  11128. * 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)
  11129. */
  11130. spriteCellChangeSpeed: number;
  11131. /**
  11132. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11133. */
  11134. startSpriteCellID: number;
  11135. /**
  11136. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11137. */
  11138. endSpriteCellID: number;
  11139. /**
  11140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11141. */
  11142. spriteCellWidth: number;
  11143. /**
  11144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11145. */
  11146. spriteCellHeight: number;
  11147. /**
  11148. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11149. */
  11150. spriteRandomStartCell: boolean;
  11151. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11152. translationPivot: Vector2;
  11153. /** @hidden */
  11154. protected _isAnimationSheetEnabled: boolean;
  11155. /**
  11156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11157. */
  11158. beginAnimationOnStart: boolean;
  11159. /**
  11160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11161. */
  11162. beginAnimationFrom: number;
  11163. /**
  11164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11165. */
  11166. beginAnimationTo: number;
  11167. /**
  11168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11169. */
  11170. beginAnimationLoop: boolean;
  11171. /**
  11172. * Gets or sets a world offset applied to all particles
  11173. */
  11174. worldOffset: Vector3;
  11175. /**
  11176. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11177. */
  11178. get isAnimationSheetEnabled(): boolean;
  11179. set isAnimationSheetEnabled(value: boolean);
  11180. /**
  11181. * Get hosting scene
  11182. * @returns the scene
  11183. */
  11184. getScene(): Scene;
  11185. /**
  11186. * You can use gravity if you want to give an orientation to your particles.
  11187. */
  11188. gravity: Vector3;
  11189. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11190. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11191. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11192. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11193. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11194. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11195. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11196. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11197. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11198. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11199. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11200. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11201. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11202. /**
  11203. * Defines the delay in milliseconds before starting the system (0 by default)
  11204. */
  11205. startDelay: number;
  11206. /**
  11207. * Gets the current list of drag gradients.
  11208. * You must use addDragGradient and removeDragGradient to udpate this list
  11209. * @returns the list of drag gradients
  11210. */
  11211. getDragGradients(): Nullable<Array<FactorGradient>>;
  11212. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11213. limitVelocityDamping: number;
  11214. /**
  11215. * Gets the current list of limit velocity gradients.
  11216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11217. * @returns the list of limit velocity gradients
  11218. */
  11219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11220. /**
  11221. * Gets the current list of color gradients.
  11222. * You must use addColorGradient and removeColorGradient to udpate this list
  11223. * @returns the list of color gradients
  11224. */
  11225. getColorGradients(): Nullable<Array<ColorGradient>>;
  11226. /**
  11227. * Gets the current list of size gradients.
  11228. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11229. * @returns the list of size gradients
  11230. */
  11231. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11232. /**
  11233. * Gets the current list of color remap gradients.
  11234. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11235. * @returns the list of color remap gradients
  11236. */
  11237. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11238. /**
  11239. * Gets the current list of alpha remap gradients.
  11240. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11241. * @returns the list of alpha remap gradients
  11242. */
  11243. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11244. /**
  11245. * Gets the current list of life time gradients.
  11246. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11247. * @returns the list of life time gradients
  11248. */
  11249. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11250. /**
  11251. * Gets the current list of angular speed gradients.
  11252. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11253. * @returns the list of angular speed gradients
  11254. */
  11255. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11256. /**
  11257. * Gets the current list of velocity gradients.
  11258. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11259. * @returns the list of velocity gradients
  11260. */
  11261. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11262. /**
  11263. * Gets the current list of start size gradients.
  11264. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11265. * @returns the list of start size gradients
  11266. */
  11267. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11268. /**
  11269. * Gets the current list of emit rate gradients.
  11270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11271. * @returns the list of emit rate gradients
  11272. */
  11273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11274. /**
  11275. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11276. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11277. */
  11278. get direction1(): Vector3;
  11279. set direction1(value: Vector3);
  11280. /**
  11281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11283. */
  11284. get direction2(): Vector3;
  11285. set direction2(value: Vector3);
  11286. /**
  11287. * 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.
  11288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11289. */
  11290. get minEmitBox(): Vector3;
  11291. set minEmitBox(value: Vector3);
  11292. /**
  11293. * 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.
  11294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11295. */
  11296. get maxEmitBox(): Vector3;
  11297. set maxEmitBox(value: Vector3);
  11298. /**
  11299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11300. */
  11301. color1: Color4;
  11302. /**
  11303. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11304. */
  11305. color2: Color4;
  11306. /**
  11307. * Color the particle will have at the end of its lifetime
  11308. */
  11309. colorDead: Color4;
  11310. /**
  11311. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11312. */
  11313. textureMask: Color4;
  11314. /**
  11315. * The particle emitter type defines the emitter used by the particle system.
  11316. * It can be for example box, sphere, or cone...
  11317. */
  11318. particleEmitterType: IParticleEmitterType;
  11319. /** @hidden */
  11320. _isSubEmitter: boolean;
  11321. /**
  11322. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11323. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11324. */
  11325. billboardMode: number;
  11326. protected _isBillboardBased: boolean;
  11327. /**
  11328. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11329. */
  11330. get isBillboardBased(): boolean;
  11331. set isBillboardBased(value: boolean);
  11332. /**
  11333. * The scene the particle system belongs to.
  11334. */
  11335. protected _scene: Scene;
  11336. /**
  11337. * Local cache of defines for image processing.
  11338. */
  11339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11340. /**
  11341. * Default configuration related to image processing available in the standard Material.
  11342. */
  11343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11344. /**
  11345. * Gets the image processing configuration used either in this material.
  11346. */
  11347. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11348. /**
  11349. * Sets the Default image processing configuration used either in the this material.
  11350. *
  11351. * If sets to null, the scene one is in use.
  11352. */
  11353. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11354. /**
  11355. * Attaches a new image processing configuration to the Standard Material.
  11356. * @param configuration
  11357. */
  11358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11359. /** @hidden */
  11360. protected _reset(): void;
  11361. /** @hidden */
  11362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11363. /**
  11364. * Instantiates a particle system.
  11365. * 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.
  11366. * @param name The name of the particle system
  11367. */
  11368. constructor(name: string);
  11369. /**
  11370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11373. * @returns the emitter
  11374. */
  11375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11376. /**
  11377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11378. * @param radius The radius of the hemisphere to emit from
  11379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11380. * @returns the emitter
  11381. */
  11382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11383. /**
  11384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11385. * @param radius The radius of the sphere to emit from
  11386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11387. * @returns the emitter
  11388. */
  11389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11390. /**
  11391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11392. * @param radius The radius of the sphere to emit from
  11393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11395. * @returns the emitter
  11396. */
  11397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11398. /**
  11399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11400. * @param radius The radius of the emission cylinder
  11401. * @param height The height of the emission cylinder
  11402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11404. * @returns the emitter
  11405. */
  11406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11407. /**
  11408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11409. * @param radius The radius of the cylinder to emit from
  11410. * @param height The height of the emission cylinder
  11411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11414. * @returns the emitter
  11415. */
  11416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11417. /**
  11418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11419. * @param radius The radius of the cone to emit from
  11420. * @param angle The base angle of the cone
  11421. * @returns the emitter
  11422. */
  11423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11424. /**
  11425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11430. * @returns the emitter
  11431. */
  11432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11433. }
  11434. }
  11435. declare module BABYLON {
  11436. /**
  11437. * Type of sub emitter
  11438. */
  11439. export enum SubEmitterType {
  11440. /**
  11441. * Attached to the particle over it's lifetime
  11442. */
  11443. ATTACHED = 0,
  11444. /**
  11445. * Created when the particle dies
  11446. */
  11447. END = 1
  11448. }
  11449. /**
  11450. * Sub emitter class used to emit particles from an existing particle
  11451. */
  11452. export class SubEmitter {
  11453. /**
  11454. * the particle system to be used by the sub emitter
  11455. */
  11456. particleSystem: ParticleSystem;
  11457. /**
  11458. * Type of the submitter (Default: END)
  11459. */
  11460. type: SubEmitterType;
  11461. /**
  11462. * 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)
  11463. * Note: This only is supported when using an emitter of type Mesh
  11464. */
  11465. inheritDirection: boolean;
  11466. /**
  11467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11468. */
  11469. inheritedVelocityAmount: number;
  11470. /**
  11471. * Creates a sub emitter
  11472. * @param particleSystem the particle system to be used by the sub emitter
  11473. */
  11474. constructor(
  11475. /**
  11476. * the particle system to be used by the sub emitter
  11477. */
  11478. particleSystem: ParticleSystem);
  11479. /**
  11480. * Clones the sub emitter
  11481. * @returns the cloned sub emitter
  11482. */
  11483. clone(): SubEmitter;
  11484. /**
  11485. * Serialize current object to a JSON object
  11486. * @returns the serialized object
  11487. */
  11488. serialize(): any;
  11489. /** @hidden */
  11490. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11491. /**
  11492. * Creates a new SubEmitter from a serialized JSON version
  11493. * @param serializationObject defines the JSON object to read from
  11494. * @param scene defines the hosting scene
  11495. * @param rootUrl defines the rootUrl for data loading
  11496. * @returns a new SubEmitter
  11497. */
  11498. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11499. /** Release associated resources */
  11500. dispose(): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /** @hidden */
  11505. export var imageProcessingDeclaration: {
  11506. name: string;
  11507. shader: string;
  11508. };
  11509. }
  11510. declare module BABYLON {
  11511. /** @hidden */
  11512. export var imageProcessingFunctions: {
  11513. name: string;
  11514. shader: string;
  11515. };
  11516. }
  11517. declare module BABYLON {
  11518. /** @hidden */
  11519. export var particlesPixelShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module BABYLON {
  11525. /** @hidden */
  11526. export var particlesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module BABYLON {
  11532. /**
  11533. * This represents a particle system in Babylon.
  11534. * 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.
  11535. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11536. * @example https://doc.babylonjs.com/babylon101/particles
  11537. */
  11538. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11539. /**
  11540. * Billboard mode will only apply to Y axis
  11541. */
  11542. static readonly BILLBOARDMODE_Y: number;
  11543. /**
  11544. * Billboard mode will apply to all axes
  11545. */
  11546. static readonly BILLBOARDMODE_ALL: number;
  11547. /**
  11548. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11549. */
  11550. static readonly BILLBOARDMODE_STRETCHED: number;
  11551. /**
  11552. * This function can be defined to provide custom update for active particles.
  11553. * This function will be called instead of regular update (age, position, color, etc.).
  11554. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11555. */
  11556. updateFunction: (particles: Particle[]) => void;
  11557. private _emitterWorldMatrix;
  11558. /**
  11559. * This function can be defined to specify initial direction for every new particle.
  11560. * It by default use the emitterType defined function
  11561. */
  11562. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11563. /**
  11564. * This function can be defined to specify initial position for every new particle.
  11565. * It by default use the emitterType defined function
  11566. */
  11567. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11568. /**
  11569. * @hidden
  11570. */
  11571. _inheritedVelocityOffset: Vector3;
  11572. /**
  11573. * An event triggered when the system is disposed
  11574. */
  11575. onDisposeObservable: Observable<ParticleSystem>;
  11576. private _onDisposeObserver;
  11577. /**
  11578. * Sets a callback that will be triggered when the system is disposed
  11579. */
  11580. set onDispose(callback: () => void);
  11581. private _particles;
  11582. private _epsilon;
  11583. private _capacity;
  11584. private _stockParticles;
  11585. private _newPartsExcess;
  11586. private _vertexData;
  11587. private _vertexBuffer;
  11588. private _vertexBuffers;
  11589. private _spriteBuffer;
  11590. private _indexBuffer;
  11591. private _effect;
  11592. private _customEffect;
  11593. private _cachedDefines;
  11594. private _scaledColorStep;
  11595. private _colorDiff;
  11596. private _scaledDirection;
  11597. private _scaledGravity;
  11598. private _currentRenderId;
  11599. private _alive;
  11600. private _useInstancing;
  11601. private _started;
  11602. private _stopped;
  11603. private _actualFrame;
  11604. private _scaledUpdateSpeed;
  11605. private _vertexBufferSize;
  11606. /** @hidden */
  11607. _currentEmitRateGradient: Nullable<FactorGradient>;
  11608. /** @hidden */
  11609. _currentEmitRate1: number;
  11610. /** @hidden */
  11611. _currentEmitRate2: number;
  11612. /** @hidden */
  11613. _currentStartSizeGradient: Nullable<FactorGradient>;
  11614. /** @hidden */
  11615. _currentStartSize1: number;
  11616. /** @hidden */
  11617. _currentStartSize2: number;
  11618. private readonly _rawTextureWidth;
  11619. private _rampGradientsTexture;
  11620. private _useRampGradients;
  11621. /** Gets or sets a boolean indicating that ramp gradients must be used
  11622. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11623. */
  11624. get useRampGradients(): boolean;
  11625. set useRampGradients(value: boolean);
  11626. /**
  11627. * 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.
  11628. * 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: [])
  11629. */
  11630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11631. private _subEmitters;
  11632. /**
  11633. * @hidden
  11634. * If the particle systems emitter should be disposed when the particle system is disposed
  11635. */
  11636. _disposeEmitterOnDispose: boolean;
  11637. /**
  11638. * The current active Sub-systems, this property is used by the root particle system only.
  11639. */
  11640. activeSubSystems: Array<ParticleSystem>;
  11641. /**
  11642. * Specifies if the particles are updated in emitter local space or world space
  11643. */
  11644. isLocal: boolean;
  11645. private _rootParticleSystem;
  11646. /**
  11647. * Gets the current list of active particles
  11648. */
  11649. get particles(): Particle[];
  11650. /**
  11651. * Returns the string "ParticleSystem"
  11652. * @returns a string containing the class name
  11653. */
  11654. getClassName(): string;
  11655. /**
  11656. * Instantiates a particle system.
  11657. * 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.
  11658. * @param name The name of the particle system
  11659. * @param capacity The max number of particles alive at the same time
  11660. * @param scene The scene the particle system belongs to
  11661. * @param customEffect a custom effect used to change the way particles are rendered by default
  11662. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11663. * @param epsilon Offset used to render the particles
  11664. */
  11665. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11666. private _addFactorGradient;
  11667. private _removeFactorGradient;
  11668. /**
  11669. * Adds a new life time gradient
  11670. * @param gradient defines the gradient to use (between 0 and 1)
  11671. * @param factor defines the life time factor to affect to the specified gradient
  11672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11673. * @returns the current particle system
  11674. */
  11675. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11676. /**
  11677. * Remove a specific life time gradient
  11678. * @param gradient defines the gradient to remove
  11679. * @returns the current particle system
  11680. */
  11681. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11682. /**
  11683. * Adds a new size gradient
  11684. * @param gradient defines the gradient to use (between 0 and 1)
  11685. * @param factor defines the size factor to affect to the specified gradient
  11686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11687. * @returns the current particle system
  11688. */
  11689. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11690. /**
  11691. * Remove a specific size gradient
  11692. * @param gradient defines the gradient to remove
  11693. * @returns the current particle system
  11694. */
  11695. removeSizeGradient(gradient: number): IParticleSystem;
  11696. /**
  11697. * Adds a new color remap gradient
  11698. * @param gradient defines the gradient to use (between 0 and 1)
  11699. * @param min defines the color remap minimal range
  11700. * @param max defines the color remap maximal range
  11701. * @returns the current particle system
  11702. */
  11703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11704. /**
  11705. * Remove a specific color remap gradient
  11706. * @param gradient defines the gradient to remove
  11707. * @returns the current particle system
  11708. */
  11709. removeColorRemapGradient(gradient: number): IParticleSystem;
  11710. /**
  11711. * Adds a new alpha remap gradient
  11712. * @param gradient defines the gradient to use (between 0 and 1)
  11713. * @param min defines the alpha remap minimal range
  11714. * @param max defines the alpha remap maximal range
  11715. * @returns the current particle system
  11716. */
  11717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11718. /**
  11719. * Remove a specific alpha remap gradient
  11720. * @param gradient defines the gradient to remove
  11721. * @returns the current particle system
  11722. */
  11723. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11724. /**
  11725. * Adds a new angular speed gradient
  11726. * @param gradient defines the gradient to use (between 0 and 1)
  11727. * @param factor defines the angular speed to affect to the specified gradient
  11728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11729. * @returns the current particle system
  11730. */
  11731. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11732. /**
  11733. * Remove a specific angular speed gradient
  11734. * @param gradient defines the gradient to remove
  11735. * @returns the current particle system
  11736. */
  11737. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11738. /**
  11739. * Adds a new velocity gradient
  11740. * @param gradient defines the gradient to use (between 0 and 1)
  11741. * @param factor defines the velocity to affect to the specified gradient
  11742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11743. * @returns the current particle system
  11744. */
  11745. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11746. /**
  11747. * Remove a specific velocity gradient
  11748. * @param gradient defines the gradient to remove
  11749. * @returns the current particle system
  11750. */
  11751. removeVelocityGradient(gradient: number): IParticleSystem;
  11752. /**
  11753. * Adds a new limit velocity gradient
  11754. * @param gradient defines the gradient to use (between 0 and 1)
  11755. * @param factor defines the limit velocity value to affect to the specified gradient
  11756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11757. * @returns the current particle system
  11758. */
  11759. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11760. /**
  11761. * Remove a specific limit velocity gradient
  11762. * @param gradient defines the gradient to remove
  11763. * @returns the current particle system
  11764. */
  11765. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11766. /**
  11767. * Adds a new drag gradient
  11768. * @param gradient defines the gradient to use (between 0 and 1)
  11769. * @param factor defines the drag value to affect to the specified gradient
  11770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11771. * @returns the current particle system
  11772. */
  11773. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11774. /**
  11775. * Remove a specific drag gradient
  11776. * @param gradient defines the gradient to remove
  11777. * @returns the current particle system
  11778. */
  11779. removeDragGradient(gradient: number): IParticleSystem;
  11780. /**
  11781. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param factor defines the emit rate value to affect to the specified gradient
  11784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11785. * @returns the current particle system
  11786. */
  11787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11788. /**
  11789. * Remove a specific emit rate gradient
  11790. * @param gradient defines the gradient to remove
  11791. * @returns the current particle system
  11792. */
  11793. removeEmitRateGradient(gradient: number): IParticleSystem;
  11794. /**
  11795. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11796. * @param gradient defines the gradient to use (between 0 and 1)
  11797. * @param factor defines the start size value to affect to the specified gradient
  11798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11799. * @returns the current particle system
  11800. */
  11801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11802. /**
  11803. * Remove a specific start size gradient
  11804. * @param gradient defines the gradient to remove
  11805. * @returns the current particle system
  11806. */
  11807. removeStartSizeGradient(gradient: number): IParticleSystem;
  11808. private _createRampGradientTexture;
  11809. /**
  11810. * Gets the current list of ramp gradients.
  11811. * You must use addRampGradient and removeRampGradient to udpate this list
  11812. * @returns the list of ramp gradients
  11813. */
  11814. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11815. /**
  11816. * Adds a new ramp gradient used to remap particle colors
  11817. * @param gradient defines the gradient to use (between 0 and 1)
  11818. * @param color defines the color to affect to the specified gradient
  11819. * @returns the current particle system
  11820. */
  11821. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11822. /**
  11823. * Remove a specific ramp gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeRampGradient(gradient: number): ParticleSystem;
  11828. /**
  11829. * Adds a new color gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param color1 defines the color to affect to the specified gradient
  11832. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11833. * @returns this particle system
  11834. */
  11835. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11836. /**
  11837. * Remove a specific color gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns this particle system
  11840. */
  11841. removeColorGradient(gradient: number): IParticleSystem;
  11842. private _fetchR;
  11843. protected _reset(): void;
  11844. private _resetEffect;
  11845. private _createVertexBuffers;
  11846. private _createIndexBuffer;
  11847. /**
  11848. * Gets the maximum number of particles active at the same time.
  11849. * @returns The max number of active particles.
  11850. */
  11851. getCapacity(): number;
  11852. /**
  11853. * Gets whether there are still active particles in the system.
  11854. * @returns True if it is alive, otherwise false.
  11855. */
  11856. isAlive(): boolean;
  11857. /**
  11858. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11859. * @returns True if it has been started, otherwise false.
  11860. */
  11861. isStarted(): boolean;
  11862. private _prepareSubEmitterInternalArray;
  11863. /**
  11864. * Starts the particle system and begins to emit
  11865. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11866. */
  11867. start(delay?: number): void;
  11868. /**
  11869. * Stops the particle system.
  11870. * @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.
  11871. */
  11872. stop(stopSubEmitters?: boolean): void;
  11873. /**
  11874. * Remove all active particles
  11875. */
  11876. reset(): void;
  11877. /**
  11878. * @hidden (for internal use only)
  11879. */
  11880. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11881. /**
  11882. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11883. * Its lifetime will start back at 0.
  11884. */
  11885. recycleParticle: (particle: Particle) => void;
  11886. private _stopSubEmitters;
  11887. private _createParticle;
  11888. private _removeFromRoot;
  11889. private _emitFromParticle;
  11890. private _update;
  11891. /** @hidden */
  11892. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11893. /** @hidden */
  11894. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11895. /** @hidden */
  11896. private _getEffect;
  11897. /**
  11898. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11899. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11900. */
  11901. animate(preWarmOnly?: boolean): void;
  11902. private _appendParticleVertices;
  11903. /**
  11904. * Rebuilds the particle system.
  11905. */
  11906. rebuild(): void;
  11907. /**
  11908. * Is this system ready to be used/rendered
  11909. * @return true if the system is ready
  11910. */
  11911. isReady(): boolean;
  11912. private _render;
  11913. /**
  11914. * Renders the particle system in its current state.
  11915. * @returns the current number of particles
  11916. */
  11917. render(): number;
  11918. /**
  11919. * Disposes the particle system and free the associated resources
  11920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11921. */
  11922. dispose(disposeTexture?: boolean): void;
  11923. /**
  11924. * Clones the particle system.
  11925. * @param name The name of the cloned object
  11926. * @param newEmitter The new emitter to use
  11927. * @returns the cloned particle system
  11928. */
  11929. clone(name: string, newEmitter: any): ParticleSystem;
  11930. /**
  11931. * Serializes the particle system to a JSON object.
  11932. * @returns the JSON object
  11933. */
  11934. serialize(): any;
  11935. /** @hidden */
  11936. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11937. /** @hidden */
  11938. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11939. /**
  11940. * Parses a JSON object to create a particle system.
  11941. * @param parsedParticleSystem The JSON object to parse
  11942. * @param scene The scene to create the particle system in
  11943. * @param rootUrl The root url to use to load external dependencies like texture
  11944. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11945. * @returns the Parsed particle system
  11946. */
  11947. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11948. }
  11949. }
  11950. declare module BABYLON {
  11951. /**
  11952. * A particle represents one of the element emitted by a particle system.
  11953. * This is mainly define by its coordinates, direction, velocity and age.
  11954. */
  11955. export class Particle {
  11956. /**
  11957. * The particle system the particle belongs to.
  11958. */
  11959. particleSystem: ParticleSystem;
  11960. private static _Count;
  11961. /**
  11962. * Unique ID of the particle
  11963. */
  11964. id: number;
  11965. /**
  11966. * The world position of the particle in the scene.
  11967. */
  11968. position: Vector3;
  11969. /**
  11970. * The world direction of the particle in the scene.
  11971. */
  11972. direction: Vector3;
  11973. /**
  11974. * The color of the particle.
  11975. */
  11976. color: Color4;
  11977. /**
  11978. * The color change of the particle per step.
  11979. */
  11980. colorStep: Color4;
  11981. /**
  11982. * Defines how long will the life of the particle be.
  11983. */
  11984. lifeTime: number;
  11985. /**
  11986. * The current age of the particle.
  11987. */
  11988. age: number;
  11989. /**
  11990. * The current size of the particle.
  11991. */
  11992. size: number;
  11993. /**
  11994. * The current scale of the particle.
  11995. */
  11996. scale: Vector2;
  11997. /**
  11998. * The current angle of the particle.
  11999. */
  12000. angle: number;
  12001. /**
  12002. * Defines how fast is the angle changing.
  12003. */
  12004. angularSpeed: number;
  12005. /**
  12006. * Defines the cell index used by the particle to be rendered from a sprite.
  12007. */
  12008. cellIndex: number;
  12009. /**
  12010. * The information required to support color remapping
  12011. */
  12012. remapData: Vector4;
  12013. /** @hidden */
  12014. _randomCellOffset?: number;
  12015. /** @hidden */
  12016. _initialDirection: Nullable<Vector3>;
  12017. /** @hidden */
  12018. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12019. /** @hidden */
  12020. _initialStartSpriteCellID: number;
  12021. /** @hidden */
  12022. _initialEndSpriteCellID: number;
  12023. /** @hidden */
  12024. _currentColorGradient: Nullable<ColorGradient>;
  12025. /** @hidden */
  12026. _currentColor1: Color4;
  12027. /** @hidden */
  12028. _currentColor2: Color4;
  12029. /** @hidden */
  12030. _currentSizeGradient: Nullable<FactorGradient>;
  12031. /** @hidden */
  12032. _currentSize1: number;
  12033. /** @hidden */
  12034. _currentSize2: number;
  12035. /** @hidden */
  12036. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12037. /** @hidden */
  12038. _currentAngularSpeed1: number;
  12039. /** @hidden */
  12040. _currentAngularSpeed2: number;
  12041. /** @hidden */
  12042. _currentVelocityGradient: Nullable<FactorGradient>;
  12043. /** @hidden */
  12044. _currentVelocity1: number;
  12045. /** @hidden */
  12046. _currentVelocity2: number;
  12047. /** @hidden */
  12048. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12049. /** @hidden */
  12050. _currentLimitVelocity1: number;
  12051. /** @hidden */
  12052. _currentLimitVelocity2: number;
  12053. /** @hidden */
  12054. _currentDragGradient: Nullable<FactorGradient>;
  12055. /** @hidden */
  12056. _currentDrag1: number;
  12057. /** @hidden */
  12058. _currentDrag2: number;
  12059. /** @hidden */
  12060. _randomNoiseCoordinates1: Vector3;
  12061. /** @hidden */
  12062. _randomNoiseCoordinates2: Vector3;
  12063. /** @hidden */
  12064. _localPosition?: Vector3;
  12065. /**
  12066. * Creates a new instance Particle
  12067. * @param particleSystem the particle system the particle belongs to
  12068. */
  12069. constructor(
  12070. /**
  12071. * The particle system the particle belongs to.
  12072. */
  12073. particleSystem: ParticleSystem);
  12074. private updateCellInfoFromSystem;
  12075. /**
  12076. * Defines how the sprite cell index is updated for the particle
  12077. */
  12078. updateCellIndex(): void;
  12079. /** @hidden */
  12080. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12081. /** @hidden */
  12082. _inheritParticleInfoToSubEmitters(): void;
  12083. /** @hidden */
  12084. _reset(): void;
  12085. /**
  12086. * Copy the properties of particle to another one.
  12087. * @param other the particle to copy the information to.
  12088. */
  12089. copyTo(other: Particle): void;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Particle emitter represents a volume emitting particles.
  12095. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12096. */
  12097. export interface IParticleEmitterType {
  12098. /**
  12099. * Called by the particle System when the direction is computed for the created particle.
  12100. * @param worldMatrix is the world matrix of the particle system
  12101. * @param directionToUpdate is the direction vector to update with the result
  12102. * @param particle is the particle we are computed the direction for
  12103. * @param isLocal defines if the direction should be set in local space
  12104. */
  12105. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12106. /**
  12107. * Called by the particle System when the position is computed for the created particle.
  12108. * @param worldMatrix is the world matrix of the particle system
  12109. * @param positionToUpdate is the position vector to update with the result
  12110. * @param particle is the particle we are computed the position for
  12111. * @param isLocal defines if the position should be set in local space
  12112. */
  12113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12114. /**
  12115. * Clones the current emitter and returns a copy of it
  12116. * @returns the new emitter
  12117. */
  12118. clone(): IParticleEmitterType;
  12119. /**
  12120. * Called by the GPUParticleSystem to setup the update shader
  12121. * @param effect defines the update shader
  12122. */
  12123. applyToShader(effect: Effect): void;
  12124. /**
  12125. * Returns a string to use to update the GPU particles update shader
  12126. * @returns the effect defines string
  12127. */
  12128. getEffectDefines(): string;
  12129. /**
  12130. * Returns a string representing the class name
  12131. * @returns a string containing the class name
  12132. */
  12133. getClassName(): string;
  12134. /**
  12135. * Serializes the particle system to a JSON object.
  12136. * @returns the JSON object
  12137. */
  12138. serialize(): any;
  12139. /**
  12140. * Parse properties from a JSON object
  12141. * @param serializationObject defines the JSON object
  12142. * @param scene defines the hosting scene
  12143. */
  12144. parse(serializationObject: any, scene: Scene): void;
  12145. }
  12146. }
  12147. declare module BABYLON {
  12148. /**
  12149. * Particle emitter emitting particles from the inside of a box.
  12150. * It emits the particles randomly between 2 given directions.
  12151. */
  12152. export class BoxParticleEmitter implements IParticleEmitterType {
  12153. /**
  12154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12155. */
  12156. direction1: Vector3;
  12157. /**
  12158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12159. */
  12160. direction2: Vector3;
  12161. /**
  12162. * 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.
  12163. */
  12164. minEmitBox: Vector3;
  12165. /**
  12166. * 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.
  12167. */
  12168. maxEmitBox: Vector3;
  12169. /**
  12170. * Creates a new instance BoxParticleEmitter
  12171. */
  12172. constructor();
  12173. /**
  12174. * Called by the particle System when the direction is computed for the created particle.
  12175. * @param worldMatrix is the world matrix of the particle system
  12176. * @param directionToUpdate is the direction vector to update with the result
  12177. * @param particle is the particle we are computed the direction for
  12178. * @param isLocal defines if the direction should be set in local space
  12179. */
  12180. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12181. /**
  12182. * Called by the particle System when the position is computed for the created particle.
  12183. * @param worldMatrix is the world matrix of the particle system
  12184. * @param positionToUpdate is the position vector to update with the result
  12185. * @param particle is the particle we are computed the position for
  12186. * @param isLocal defines if the position should be set in local space
  12187. */
  12188. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12189. /**
  12190. * Clones the current emitter and returns a copy of it
  12191. * @returns the new emitter
  12192. */
  12193. clone(): BoxParticleEmitter;
  12194. /**
  12195. * Called by the GPUParticleSystem to setup the update shader
  12196. * @param effect defines the update shader
  12197. */
  12198. applyToShader(effect: Effect): void;
  12199. /**
  12200. * Returns a string to use to update the GPU particles update shader
  12201. * @returns a string containng the defines string
  12202. */
  12203. getEffectDefines(): string;
  12204. /**
  12205. * Returns the string "BoxParticleEmitter"
  12206. * @returns a string containing the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Serializes the particle system to a JSON object.
  12211. * @returns the JSON object
  12212. */
  12213. serialize(): any;
  12214. /**
  12215. * Parse properties from a JSON object
  12216. * @param serializationObject defines the JSON object
  12217. */
  12218. parse(serializationObject: any): void;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Particle emitter emitting particles from the inside of a cone.
  12224. * It emits the particles alongside the cone volume from the base to the particle.
  12225. * The emission direction might be randomized.
  12226. */
  12227. export class ConeParticleEmitter implements IParticleEmitterType {
  12228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12229. directionRandomizer: number;
  12230. private _radius;
  12231. private _angle;
  12232. private _height;
  12233. /**
  12234. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12235. */
  12236. radiusRange: number;
  12237. /**
  12238. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12239. */
  12240. heightRange: number;
  12241. /**
  12242. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12243. */
  12244. emitFromSpawnPointOnly: boolean;
  12245. /**
  12246. * Gets or sets the radius of the emission cone
  12247. */
  12248. get radius(): number;
  12249. set radius(value: number);
  12250. /**
  12251. * Gets or sets the angle of the emission cone
  12252. */
  12253. get angle(): number;
  12254. set angle(value: number);
  12255. private _buildHeight;
  12256. /**
  12257. * Creates a new instance ConeParticleEmitter
  12258. * @param radius the radius of the emission cone (1 by default)
  12259. * @param angle the cone base angle (PI by default)
  12260. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12261. */
  12262. constructor(radius?: number, angle?: number,
  12263. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12264. directionRandomizer?: number);
  12265. /**
  12266. * Called by the particle System when the direction is computed for the created particle.
  12267. * @param worldMatrix is the world matrix of the particle system
  12268. * @param directionToUpdate is the direction vector to update with the result
  12269. * @param particle is the particle we are computed the direction for
  12270. * @param isLocal defines if the direction should be set in local space
  12271. */
  12272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12273. /**
  12274. * Called by the particle System when the position is computed for the created particle.
  12275. * @param worldMatrix is the world matrix of the particle system
  12276. * @param positionToUpdate is the position vector to update with the result
  12277. * @param particle is the particle we are computed the position for
  12278. * @param isLocal defines if the position should be set in local space
  12279. */
  12280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12281. /**
  12282. * Clones the current emitter and returns a copy of it
  12283. * @returns the new emitter
  12284. */
  12285. clone(): ConeParticleEmitter;
  12286. /**
  12287. * Called by the GPUParticleSystem to setup the update shader
  12288. * @param effect defines the update shader
  12289. */
  12290. applyToShader(effect: Effect): void;
  12291. /**
  12292. * Returns a string to use to update the GPU particles update shader
  12293. * @returns a string containng the defines string
  12294. */
  12295. getEffectDefines(): string;
  12296. /**
  12297. * Returns the string "ConeParticleEmitter"
  12298. * @returns a string containing the class name
  12299. */
  12300. getClassName(): string;
  12301. /**
  12302. * Serializes the particle system to a JSON object.
  12303. * @returns the JSON object
  12304. */
  12305. serialize(): any;
  12306. /**
  12307. * Parse properties from a JSON object
  12308. * @param serializationObject defines the JSON object
  12309. */
  12310. parse(serializationObject: any): void;
  12311. }
  12312. }
  12313. declare module BABYLON {
  12314. /**
  12315. * Particle emitter emitting particles from the inside of a cylinder.
  12316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12317. */
  12318. export class CylinderParticleEmitter implements IParticleEmitterType {
  12319. /**
  12320. * The radius of the emission cylinder.
  12321. */
  12322. radius: number;
  12323. /**
  12324. * The height of the emission cylinder.
  12325. */
  12326. height: number;
  12327. /**
  12328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12329. */
  12330. radiusRange: number;
  12331. /**
  12332. * How much to randomize the particle direction [0-1].
  12333. */
  12334. directionRandomizer: number;
  12335. /**
  12336. * Creates a new instance CylinderParticleEmitter
  12337. * @param radius the radius of the emission cylinder (1 by default)
  12338. * @param height the height of the emission cylinder (1 by default)
  12339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12341. */
  12342. constructor(
  12343. /**
  12344. * The radius of the emission cylinder.
  12345. */
  12346. radius?: number,
  12347. /**
  12348. * The height of the emission cylinder.
  12349. */
  12350. height?: number,
  12351. /**
  12352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12353. */
  12354. radiusRange?: number,
  12355. /**
  12356. * How much to randomize the particle direction [0-1].
  12357. */
  12358. directionRandomizer?: number);
  12359. /**
  12360. * Called by the particle System when the direction is computed for the created particle.
  12361. * @param worldMatrix is the world matrix of the particle system
  12362. * @param directionToUpdate is the direction vector to update with the result
  12363. * @param particle is the particle we are computed the direction for
  12364. * @param isLocal defines if the direction should be set in local space
  12365. */
  12366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12367. /**
  12368. * Called by the particle System when the position is computed for the created particle.
  12369. * @param worldMatrix is the world matrix of the particle system
  12370. * @param positionToUpdate is the position vector to update with the result
  12371. * @param particle is the particle we are computed the position for
  12372. * @param isLocal defines if the position should be set in local space
  12373. */
  12374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12375. /**
  12376. * Clones the current emitter and returns a copy of it
  12377. * @returns the new emitter
  12378. */
  12379. clone(): CylinderParticleEmitter;
  12380. /**
  12381. * Called by the GPUParticleSystem to setup the update shader
  12382. * @param effect defines the update shader
  12383. */
  12384. applyToShader(effect: Effect): void;
  12385. /**
  12386. * Returns a string to use to update the GPU particles update shader
  12387. * @returns a string containng the defines string
  12388. */
  12389. getEffectDefines(): string;
  12390. /**
  12391. * Returns the string "CylinderParticleEmitter"
  12392. * @returns a string containing the class name
  12393. */
  12394. getClassName(): string;
  12395. /**
  12396. * Serializes the particle system to a JSON object.
  12397. * @returns the JSON object
  12398. */
  12399. serialize(): any;
  12400. /**
  12401. * Parse properties from a JSON object
  12402. * @param serializationObject defines the JSON object
  12403. */
  12404. parse(serializationObject: any): void;
  12405. }
  12406. /**
  12407. * Particle emitter emitting particles from the inside of a cylinder.
  12408. * It emits the particles randomly between two vectors.
  12409. */
  12410. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12411. /**
  12412. * The min limit of the emission direction.
  12413. */
  12414. direction1: Vector3;
  12415. /**
  12416. * The max limit of the emission direction.
  12417. */
  12418. direction2: Vector3;
  12419. /**
  12420. * Creates a new instance CylinderDirectedParticleEmitter
  12421. * @param radius the radius of the emission cylinder (1 by default)
  12422. * @param height the height of the emission cylinder (1 by default)
  12423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12424. * @param direction1 the min limit of the emission direction (up vector by default)
  12425. * @param direction2 the max limit of the emission direction (up vector by default)
  12426. */
  12427. constructor(radius?: number, height?: number, radiusRange?: number,
  12428. /**
  12429. * The min limit of the emission direction.
  12430. */
  12431. direction1?: Vector3,
  12432. /**
  12433. * The max limit of the emission direction.
  12434. */
  12435. direction2?: Vector3);
  12436. /**
  12437. * Called by the particle System when the direction is computed for the created particle.
  12438. * @param worldMatrix is the world matrix of the particle system
  12439. * @param directionToUpdate is the direction vector to update with the result
  12440. * @param particle is the particle we are computed the direction for
  12441. */
  12442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12443. /**
  12444. * Clones the current emitter and returns a copy of it
  12445. * @returns the new emitter
  12446. */
  12447. clone(): CylinderDirectedParticleEmitter;
  12448. /**
  12449. * Called by the GPUParticleSystem to setup the update shader
  12450. * @param effect defines the update shader
  12451. */
  12452. applyToShader(effect: Effect): void;
  12453. /**
  12454. * Returns a string to use to update the GPU particles update shader
  12455. * @returns a string containng the defines string
  12456. */
  12457. getEffectDefines(): string;
  12458. /**
  12459. * Returns the string "CylinderDirectedParticleEmitter"
  12460. * @returns a string containing the class name
  12461. */
  12462. getClassName(): string;
  12463. /**
  12464. * Serializes the particle system to a JSON object.
  12465. * @returns the JSON object
  12466. */
  12467. serialize(): any;
  12468. /**
  12469. * Parse properties from a JSON object
  12470. * @param serializationObject defines the JSON object
  12471. */
  12472. parse(serializationObject: any): void;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * Particle emitter emitting particles from the inside of a hemisphere.
  12478. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12479. */
  12480. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12481. /**
  12482. * The radius of the emission hemisphere.
  12483. */
  12484. radius: number;
  12485. /**
  12486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12487. */
  12488. radiusRange: number;
  12489. /**
  12490. * How much to randomize the particle direction [0-1].
  12491. */
  12492. directionRandomizer: number;
  12493. /**
  12494. * Creates a new instance HemisphericParticleEmitter
  12495. * @param radius the radius of the emission hemisphere (1 by default)
  12496. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12498. */
  12499. constructor(
  12500. /**
  12501. * The radius of the emission hemisphere.
  12502. */
  12503. radius?: number,
  12504. /**
  12505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12506. */
  12507. radiusRange?: number,
  12508. /**
  12509. * How much to randomize the particle direction [0-1].
  12510. */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): HemisphericParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "HemisphericParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. /**
  12562. * Particle emitter emitting particles from a point.
  12563. * It emits the particles randomly between 2 given directions.
  12564. */
  12565. export class PointParticleEmitter implements IParticleEmitterType {
  12566. /**
  12567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12568. */
  12569. direction1: Vector3;
  12570. /**
  12571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12572. */
  12573. direction2: Vector3;
  12574. /**
  12575. * Creates a new instance PointParticleEmitter
  12576. */
  12577. constructor();
  12578. /**
  12579. * Called by the particle System when the direction is computed for the created particle.
  12580. * @param worldMatrix is the world matrix of the particle system
  12581. * @param directionToUpdate is the direction vector to update with the result
  12582. * @param particle is the particle we are computed the direction for
  12583. * @param isLocal defines if the direction should be set in local space
  12584. */
  12585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12586. /**
  12587. * Called by the particle System when the position is computed for the created particle.
  12588. * @param worldMatrix is the world matrix of the particle system
  12589. * @param positionToUpdate is the position vector to update with the result
  12590. * @param particle is the particle we are computed the position for
  12591. * @param isLocal defines if the position should be set in local space
  12592. */
  12593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12594. /**
  12595. * Clones the current emitter and returns a copy of it
  12596. * @returns the new emitter
  12597. */
  12598. clone(): PointParticleEmitter;
  12599. /**
  12600. * Called by the GPUParticleSystem to setup the update shader
  12601. * @param effect defines the update shader
  12602. */
  12603. applyToShader(effect: Effect): void;
  12604. /**
  12605. * Returns a string to use to update the GPU particles update shader
  12606. * @returns a string containng the defines string
  12607. */
  12608. getEffectDefines(): string;
  12609. /**
  12610. * Returns the string "PointParticleEmitter"
  12611. * @returns a string containing the class name
  12612. */
  12613. getClassName(): string;
  12614. /**
  12615. * Serializes the particle system to a JSON object.
  12616. * @returns the JSON object
  12617. */
  12618. serialize(): any;
  12619. /**
  12620. * Parse properties from a JSON object
  12621. * @param serializationObject defines the JSON object
  12622. */
  12623. parse(serializationObject: any): void;
  12624. }
  12625. }
  12626. declare module BABYLON {
  12627. /**
  12628. * Particle emitter emitting particles from the inside of a sphere.
  12629. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12630. */
  12631. export class SphereParticleEmitter implements IParticleEmitterType {
  12632. /**
  12633. * The radius of the emission sphere.
  12634. */
  12635. radius: number;
  12636. /**
  12637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12638. */
  12639. radiusRange: number;
  12640. /**
  12641. * How much to randomize the particle direction [0-1].
  12642. */
  12643. directionRandomizer: number;
  12644. /**
  12645. * Creates a new instance SphereParticleEmitter
  12646. * @param radius the radius of the emission sphere (1 by default)
  12647. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12649. */
  12650. constructor(
  12651. /**
  12652. * The radius of the emission sphere.
  12653. */
  12654. radius?: number,
  12655. /**
  12656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12657. */
  12658. radiusRange?: number,
  12659. /**
  12660. * How much to randomize the particle direction [0-1].
  12661. */
  12662. directionRandomizer?: number);
  12663. /**
  12664. * Called by the particle System when the direction is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param directionToUpdate is the direction vector to update with the result
  12667. * @param particle is the particle we are computed the direction for
  12668. * @param isLocal defines if the direction should be set in local space
  12669. */
  12670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Called by the particle System when the position is computed for the created particle.
  12673. * @param worldMatrix is the world matrix of the particle system
  12674. * @param positionToUpdate is the position vector to update with the result
  12675. * @param particle is the particle we are computed the position for
  12676. * @param isLocal defines if the position should be set in local space
  12677. */
  12678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12679. /**
  12680. * Clones the current emitter and returns a copy of it
  12681. * @returns the new emitter
  12682. */
  12683. clone(): SphereParticleEmitter;
  12684. /**
  12685. * Called by the GPUParticleSystem to setup the update shader
  12686. * @param effect defines the update shader
  12687. */
  12688. applyToShader(effect: Effect): void;
  12689. /**
  12690. * Returns a string to use to update the GPU particles update shader
  12691. * @returns a string containng the defines string
  12692. */
  12693. getEffectDefines(): string;
  12694. /**
  12695. * Returns the string "SphereParticleEmitter"
  12696. * @returns a string containing the class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Serializes the particle system to a JSON object.
  12701. * @returns the JSON object
  12702. */
  12703. serialize(): any;
  12704. /**
  12705. * Parse properties from a JSON object
  12706. * @param serializationObject defines the JSON object
  12707. */
  12708. parse(serializationObject: any): void;
  12709. }
  12710. /**
  12711. * Particle emitter emitting particles from the inside of a sphere.
  12712. * It emits the particles randomly between two vectors.
  12713. */
  12714. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12715. /**
  12716. * The min limit of the emission direction.
  12717. */
  12718. direction1: Vector3;
  12719. /**
  12720. * The max limit of the emission direction.
  12721. */
  12722. direction2: Vector3;
  12723. /**
  12724. * Creates a new instance SphereDirectedParticleEmitter
  12725. * @param radius the radius of the emission sphere (1 by default)
  12726. * @param direction1 the min limit of the emission direction (up vector by default)
  12727. * @param direction2 the max limit of the emission direction (up vector by default)
  12728. */
  12729. constructor(radius?: number,
  12730. /**
  12731. * The min limit of the emission direction.
  12732. */
  12733. direction1?: Vector3,
  12734. /**
  12735. * The max limit of the emission direction.
  12736. */
  12737. direction2?: Vector3);
  12738. /**
  12739. * Called by the particle System when the direction is computed for the created particle.
  12740. * @param worldMatrix is the world matrix of the particle system
  12741. * @param directionToUpdate is the direction vector to update with the result
  12742. * @param particle is the particle we are computed the direction for
  12743. */
  12744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12745. /**
  12746. * Clones the current emitter and returns a copy of it
  12747. * @returns the new emitter
  12748. */
  12749. clone(): SphereDirectedParticleEmitter;
  12750. /**
  12751. * Called by the GPUParticleSystem to setup the update shader
  12752. * @param effect defines the update shader
  12753. */
  12754. applyToShader(effect: Effect): void;
  12755. /**
  12756. * Returns a string to use to update the GPU particles update shader
  12757. * @returns a string containng the defines string
  12758. */
  12759. getEffectDefines(): string;
  12760. /**
  12761. * Returns the string "SphereDirectedParticleEmitter"
  12762. * @returns a string containing the class name
  12763. */
  12764. getClassName(): string;
  12765. /**
  12766. * Serializes the particle system to a JSON object.
  12767. * @returns the JSON object
  12768. */
  12769. serialize(): any;
  12770. /**
  12771. * Parse properties from a JSON object
  12772. * @param serializationObject defines the JSON object
  12773. */
  12774. parse(serializationObject: any): void;
  12775. }
  12776. }
  12777. declare module BABYLON {
  12778. /**
  12779. * Particle emitter emitting particles from a custom list of positions.
  12780. */
  12781. export class CustomParticleEmitter implements IParticleEmitterType {
  12782. /**
  12783. * Gets or sets the position generator that will create the inital position of each particle.
  12784. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12785. */
  12786. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12787. /**
  12788. * Gets or sets the destination generator that will create the final destination of each particle.
  12789. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12790. */
  12791. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12792. /**
  12793. * Creates a new instance CustomParticleEmitter
  12794. */
  12795. constructor();
  12796. /**
  12797. * Called by the particle System when the direction is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param directionToUpdate is the direction vector to update with the result
  12800. * @param particle is the particle we are computed the direction for
  12801. * @param isLocal defines if the direction should be set in local space
  12802. */
  12803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Called by the particle System when the position is computed for the created particle.
  12806. * @param worldMatrix is the world matrix of the particle system
  12807. * @param positionToUpdate is the position vector to update with the result
  12808. * @param particle is the particle we are computed the position for
  12809. * @param isLocal defines if the position should be set in local space
  12810. */
  12811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12812. /**
  12813. * Clones the current emitter and returns a copy of it
  12814. * @returns the new emitter
  12815. */
  12816. clone(): CustomParticleEmitter;
  12817. /**
  12818. * Called by the GPUParticleSystem to setup the update shader
  12819. * @param effect defines the update shader
  12820. */
  12821. applyToShader(effect: Effect): void;
  12822. /**
  12823. * Returns a string to use to update the GPU particles update shader
  12824. * @returns a string containng the defines string
  12825. */
  12826. getEffectDefines(): string;
  12827. /**
  12828. * Returns the string "PointParticleEmitter"
  12829. * @returns a string containing the class name
  12830. */
  12831. getClassName(): string;
  12832. /**
  12833. * Serializes the particle system to a JSON object.
  12834. * @returns the JSON object
  12835. */
  12836. serialize(): any;
  12837. /**
  12838. * Parse properties from a JSON object
  12839. * @param serializationObject defines the JSON object
  12840. */
  12841. parse(serializationObject: any): void;
  12842. }
  12843. }
  12844. declare module BABYLON {
  12845. /**
  12846. * Particle emitter emitting particles from the inside of a box.
  12847. * It emits the particles randomly between 2 given directions.
  12848. */
  12849. export class MeshParticleEmitter implements IParticleEmitterType {
  12850. private _indices;
  12851. private _positions;
  12852. private _normals;
  12853. private _storedNormal;
  12854. private _mesh;
  12855. /**
  12856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12857. */
  12858. direction1: Vector3;
  12859. /**
  12860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12861. */
  12862. direction2: Vector3;
  12863. /**
  12864. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12865. */
  12866. useMeshNormalsForDirection: boolean;
  12867. /** Defines the mesh to use as source */
  12868. get mesh(): Nullable<AbstractMesh>;
  12869. set mesh(value: Nullable<AbstractMesh>);
  12870. /**
  12871. * Creates a new instance MeshParticleEmitter
  12872. * @param mesh defines the mesh to use as source
  12873. */
  12874. constructor(mesh?: Nullable<AbstractMesh>);
  12875. /**
  12876. * Called by the particle System when the direction is computed for the created particle.
  12877. * @param worldMatrix is the world matrix of the particle system
  12878. * @param directionToUpdate is the direction vector to update with the result
  12879. * @param particle is the particle we are computed the direction for
  12880. * @param isLocal defines if the direction should be set in local space
  12881. */
  12882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12883. /**
  12884. * Called by the particle System when the position is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param positionToUpdate is the position vector to update with the result
  12887. * @param particle is the particle we are computed the position for
  12888. * @param isLocal defines if the position should be set in local space
  12889. */
  12890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Clones the current emitter and returns a copy of it
  12893. * @returns the new emitter
  12894. */
  12895. clone(): MeshParticleEmitter;
  12896. /**
  12897. * Called by the GPUParticleSystem to setup the update shader
  12898. * @param effect defines the update shader
  12899. */
  12900. applyToShader(effect: Effect): void;
  12901. /**
  12902. * Returns a string to use to update the GPU particles update shader
  12903. * @returns a string containng the defines string
  12904. */
  12905. getEffectDefines(): string;
  12906. /**
  12907. * Returns the string "BoxParticleEmitter"
  12908. * @returns a string containing the class name
  12909. */
  12910. getClassName(): string;
  12911. /**
  12912. * Serializes the particle system to a JSON object.
  12913. * @returns the JSON object
  12914. */
  12915. serialize(): any;
  12916. /**
  12917. * Parse properties from a JSON object
  12918. * @param serializationObject defines the JSON object
  12919. * @param scene defines the hosting scene
  12920. */
  12921. parse(serializationObject: any, scene: Scene): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. /**
  12926. * Interface representing a particle system in Babylon.js.
  12927. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12928. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12929. */
  12930. export interface IParticleSystem {
  12931. /**
  12932. * List of animations used by the particle system.
  12933. */
  12934. animations: Animation[];
  12935. /**
  12936. * The id of the Particle system.
  12937. */
  12938. id: string;
  12939. /**
  12940. * The name of the Particle system.
  12941. */
  12942. name: string;
  12943. /**
  12944. * The emitter represents the Mesh or position we are attaching the particle system to.
  12945. */
  12946. emitter: Nullable<AbstractMesh | Vector3>;
  12947. /**
  12948. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12949. */
  12950. isBillboardBased: boolean;
  12951. /**
  12952. * The rendering group used by the Particle system to chose when to render.
  12953. */
  12954. renderingGroupId: number;
  12955. /**
  12956. * The layer mask we are rendering the particles through.
  12957. */
  12958. layerMask: number;
  12959. /**
  12960. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12961. */
  12962. updateSpeed: number;
  12963. /**
  12964. * The amount of time the particle system is running (depends of the overall update speed).
  12965. */
  12966. targetStopDuration: number;
  12967. /**
  12968. * The texture used to render each particle. (this can be a spritesheet)
  12969. */
  12970. particleTexture: Nullable<Texture>;
  12971. /**
  12972. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12973. */
  12974. blendMode: number;
  12975. /**
  12976. * Minimum life time of emitting particles.
  12977. */
  12978. minLifeTime: number;
  12979. /**
  12980. * Maximum life time of emitting particles.
  12981. */
  12982. maxLifeTime: number;
  12983. /**
  12984. * Minimum Size of emitting particles.
  12985. */
  12986. minSize: number;
  12987. /**
  12988. * Maximum Size of emitting particles.
  12989. */
  12990. maxSize: number;
  12991. /**
  12992. * Minimum scale of emitting particles on X axis.
  12993. */
  12994. minScaleX: number;
  12995. /**
  12996. * Maximum scale of emitting particles on X axis.
  12997. */
  12998. maxScaleX: number;
  12999. /**
  13000. * Minimum scale of emitting particles on Y axis.
  13001. */
  13002. minScaleY: number;
  13003. /**
  13004. * Maximum scale of emitting particles on Y axis.
  13005. */
  13006. maxScaleY: number;
  13007. /**
  13008. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13009. */
  13010. color1: Color4;
  13011. /**
  13012. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13013. */
  13014. color2: Color4;
  13015. /**
  13016. * Color the particle will have at the end of its lifetime.
  13017. */
  13018. colorDead: Color4;
  13019. /**
  13020. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13021. */
  13022. emitRate: number;
  13023. /**
  13024. * You can use gravity if you want to give an orientation to your particles.
  13025. */
  13026. gravity: Vector3;
  13027. /**
  13028. * Minimum power of emitting particles.
  13029. */
  13030. minEmitPower: number;
  13031. /**
  13032. * Maximum power of emitting particles.
  13033. */
  13034. maxEmitPower: number;
  13035. /**
  13036. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13037. */
  13038. minAngularSpeed: number;
  13039. /**
  13040. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13041. */
  13042. maxAngularSpeed: number;
  13043. /**
  13044. * Gets or sets the minimal initial rotation in radians.
  13045. */
  13046. minInitialRotation: number;
  13047. /**
  13048. * Gets or sets the maximal initial rotation in radians.
  13049. */
  13050. maxInitialRotation: number;
  13051. /**
  13052. * The particle emitter type defines the emitter used by the particle system.
  13053. * It can be for example box, sphere, or cone...
  13054. */
  13055. particleEmitterType: Nullable<IParticleEmitterType>;
  13056. /**
  13057. * Defines the delay in milliseconds before starting the system (0 by default)
  13058. */
  13059. startDelay: number;
  13060. /**
  13061. * 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
  13062. */
  13063. preWarmCycles: number;
  13064. /**
  13065. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13066. */
  13067. preWarmStepOffset: number;
  13068. /**
  13069. * 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)
  13070. */
  13071. spriteCellChangeSpeed: number;
  13072. /**
  13073. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13074. */
  13075. startSpriteCellID: number;
  13076. /**
  13077. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13078. */
  13079. endSpriteCellID: number;
  13080. /**
  13081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13082. */
  13083. spriteCellWidth: number;
  13084. /**
  13085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13086. */
  13087. spriteCellHeight: number;
  13088. /**
  13089. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13090. */
  13091. spriteRandomStartCell: boolean;
  13092. /**
  13093. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13094. */
  13095. isAnimationSheetEnabled: boolean;
  13096. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13097. translationPivot: Vector2;
  13098. /**
  13099. * Gets or sets a texture used to add random noise to particle positions
  13100. */
  13101. noiseTexture: Nullable<BaseTexture>;
  13102. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13103. noiseStrength: Vector3;
  13104. /**
  13105. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13106. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13107. */
  13108. billboardMode: number;
  13109. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13110. limitVelocityDamping: number;
  13111. /**
  13112. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13113. */
  13114. beginAnimationOnStart: boolean;
  13115. /**
  13116. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13117. */
  13118. beginAnimationFrom: number;
  13119. /**
  13120. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13121. */
  13122. beginAnimationTo: number;
  13123. /**
  13124. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13125. */
  13126. beginAnimationLoop: boolean;
  13127. /**
  13128. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13129. */
  13130. disposeOnStop: boolean;
  13131. /**
  13132. * Specifies if the particles are updated in emitter local space or world space
  13133. */
  13134. isLocal: boolean;
  13135. /**
  13136. * Gets the maximum number of particles active at the same time.
  13137. * @returns The max number of active particles.
  13138. */
  13139. getCapacity(): number;
  13140. /**
  13141. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13142. * @returns True if it has been started, otherwise false.
  13143. */
  13144. isStarted(): boolean;
  13145. /**
  13146. * Animates the particle system for this frame.
  13147. */
  13148. animate(): void;
  13149. /**
  13150. * Renders the particle system in its current state.
  13151. * @returns the current number of particles
  13152. */
  13153. render(): number;
  13154. /**
  13155. * Dispose the particle system and frees its associated resources.
  13156. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13157. */
  13158. dispose(disposeTexture?: boolean): void;
  13159. /**
  13160. * Clones the particle system.
  13161. * @param name The name of the cloned object
  13162. * @param newEmitter The new emitter to use
  13163. * @returns the cloned particle system
  13164. */
  13165. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13166. /**
  13167. * Serializes the particle system to a JSON object.
  13168. * @returns the JSON object
  13169. */
  13170. serialize(): any;
  13171. /**
  13172. * Rebuild the particle system
  13173. */
  13174. rebuild(): void;
  13175. /**
  13176. * Starts the particle system and begins to emit
  13177. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13178. */
  13179. start(delay?: number): void;
  13180. /**
  13181. * Stops the particle system.
  13182. */
  13183. stop(): void;
  13184. /**
  13185. * Remove all active particles
  13186. */
  13187. reset(): void;
  13188. /**
  13189. * Is this system ready to be used/rendered
  13190. * @return true if the system is ready
  13191. */
  13192. isReady(): boolean;
  13193. /**
  13194. * Returns the string "ParticleSystem"
  13195. * @returns a string containing the class name
  13196. */
  13197. getClassName(): string;
  13198. /**
  13199. * Adds a new color gradient
  13200. * @param gradient defines the gradient to use (between 0 and 1)
  13201. * @param color1 defines the color to affect to the specified gradient
  13202. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13203. * @returns the current particle system
  13204. */
  13205. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13206. /**
  13207. * Remove a specific color gradient
  13208. * @param gradient defines the gradient to remove
  13209. * @returns the current particle system
  13210. */
  13211. removeColorGradient(gradient: number): IParticleSystem;
  13212. /**
  13213. * Adds a new size gradient
  13214. * @param gradient defines the gradient to use (between 0 and 1)
  13215. * @param factor defines the size factor to affect to the specified gradient
  13216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13217. * @returns the current particle system
  13218. */
  13219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13220. /**
  13221. * Remove a specific size gradient
  13222. * @param gradient defines the gradient to remove
  13223. * @returns the current particle system
  13224. */
  13225. removeSizeGradient(gradient: number): IParticleSystem;
  13226. /**
  13227. * Gets the current list of color gradients.
  13228. * You must use addColorGradient and removeColorGradient to udpate this list
  13229. * @returns the list of color gradients
  13230. */
  13231. getColorGradients(): Nullable<Array<ColorGradient>>;
  13232. /**
  13233. * Gets the current list of size gradients.
  13234. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13235. * @returns the list of size gradients
  13236. */
  13237. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13238. /**
  13239. * Gets the current list of angular speed gradients.
  13240. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13241. * @returns the list of angular speed gradients
  13242. */
  13243. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13244. /**
  13245. * Adds a new angular speed gradient
  13246. * @param gradient defines the gradient to use (between 0 and 1)
  13247. * @param factor defines the angular speed to affect to the specified gradient
  13248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13249. * @returns the current particle system
  13250. */
  13251. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13252. /**
  13253. * Remove a specific angular speed gradient
  13254. * @param gradient defines the gradient to remove
  13255. * @returns the current particle system
  13256. */
  13257. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13258. /**
  13259. * Gets the current list of velocity gradients.
  13260. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13261. * @returns the list of velocity gradients
  13262. */
  13263. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13264. /**
  13265. * Adds a new velocity gradient
  13266. * @param gradient defines the gradient to use (between 0 and 1)
  13267. * @param factor defines the velocity to affect to the specified gradient
  13268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13269. * @returns the current particle system
  13270. */
  13271. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13272. /**
  13273. * Remove a specific velocity gradient
  13274. * @param gradient defines the gradient to remove
  13275. * @returns the current particle system
  13276. */
  13277. removeVelocityGradient(gradient: number): IParticleSystem;
  13278. /**
  13279. * Gets the current list of limit velocity gradients.
  13280. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13281. * @returns the list of limit velocity gradients
  13282. */
  13283. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13284. /**
  13285. * Adds a new limit velocity gradient
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param factor defines the limit velocity to affect to the specified gradient
  13288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13289. * @returns the current particle system
  13290. */
  13291. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13292. /**
  13293. * Remove a specific limit velocity gradient
  13294. * @param gradient defines the gradient to remove
  13295. * @returns the current particle system
  13296. */
  13297. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13298. /**
  13299. * Adds a new drag gradient
  13300. * @param gradient defines the gradient to use (between 0 and 1)
  13301. * @param factor defines the drag to affect to the specified gradient
  13302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13303. * @returns the current particle system
  13304. */
  13305. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13306. /**
  13307. * Remove a specific drag gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeDragGradient(gradient: number): IParticleSystem;
  13312. /**
  13313. * Gets the current list of drag gradients.
  13314. * You must use addDragGradient and removeDragGradient to udpate this list
  13315. * @returns the list of drag gradients
  13316. */
  13317. getDragGradients(): Nullable<Array<FactorGradient>>;
  13318. /**
  13319. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13320. * @param gradient defines the gradient to use (between 0 and 1)
  13321. * @param factor defines the emit rate to affect to the specified gradient
  13322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13323. * @returns the current particle system
  13324. */
  13325. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13326. /**
  13327. * Remove a specific emit rate gradient
  13328. * @param gradient defines the gradient to remove
  13329. * @returns the current particle system
  13330. */
  13331. removeEmitRateGradient(gradient: number): IParticleSystem;
  13332. /**
  13333. * Gets the current list of emit rate gradients.
  13334. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13335. * @returns the list of emit rate gradients
  13336. */
  13337. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13338. /**
  13339. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13340. * @param gradient defines the gradient to use (between 0 and 1)
  13341. * @param factor defines the start size to affect to the specified gradient
  13342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13343. * @returns the current particle system
  13344. */
  13345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13346. /**
  13347. * Remove a specific start size gradient
  13348. * @param gradient defines the gradient to remove
  13349. * @returns the current particle system
  13350. */
  13351. removeStartSizeGradient(gradient: number): IParticleSystem;
  13352. /**
  13353. * Gets the current list of start size gradients.
  13354. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13355. * @returns the list of start size gradients
  13356. */
  13357. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13358. /**
  13359. * Adds a new life time gradient
  13360. * @param gradient defines the gradient to use (between 0 and 1)
  13361. * @param factor defines the life time factor to affect to the specified gradient
  13362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13363. * @returns the current particle system
  13364. */
  13365. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13366. /**
  13367. * Remove a specific life time gradient
  13368. * @param gradient defines the gradient to remove
  13369. * @returns the current particle system
  13370. */
  13371. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13372. /**
  13373. * Gets the current list of life time gradients.
  13374. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13375. * @returns the list of life time gradients
  13376. */
  13377. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13378. /**
  13379. * Gets the current list of color gradients.
  13380. * You must use addColorGradient and removeColorGradient to udpate this list
  13381. * @returns the list of color gradients
  13382. */
  13383. getColorGradients(): Nullable<Array<ColorGradient>>;
  13384. /**
  13385. * Adds a new ramp gradient used to remap particle colors
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param color defines the color to affect to the specified gradient
  13388. * @returns the current particle system
  13389. */
  13390. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13391. /**
  13392. * Gets the current list of ramp gradients.
  13393. * You must use addRampGradient and removeRampGradient to udpate this list
  13394. * @returns the list of ramp gradients
  13395. */
  13396. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13397. /** Gets or sets a boolean indicating that ramp gradients must be used
  13398. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13399. */
  13400. useRampGradients: boolean;
  13401. /**
  13402. * Adds a new color remap gradient
  13403. * @param gradient defines the gradient to use (between 0 and 1)
  13404. * @param min defines the color remap minimal range
  13405. * @param max defines the color remap maximal range
  13406. * @returns the current particle system
  13407. */
  13408. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13409. /**
  13410. * Gets the current list of color remap gradients.
  13411. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13412. * @returns the list of color remap gradients
  13413. */
  13414. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13415. /**
  13416. * Adds a new alpha remap gradient
  13417. * @param gradient defines the gradient to use (between 0 and 1)
  13418. * @param min defines the alpha remap minimal range
  13419. * @param max defines the alpha remap maximal range
  13420. * @returns the current particle system
  13421. */
  13422. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13423. /**
  13424. * Gets the current list of alpha remap gradients.
  13425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13426. * @returns the list of alpha remap gradients
  13427. */
  13428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13429. /**
  13430. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13431. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13432. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13433. * @returns the emitter
  13434. */
  13435. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13436. /**
  13437. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13438. * @param radius The radius of the hemisphere to emit from
  13439. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13440. * @returns the emitter
  13441. */
  13442. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13443. /**
  13444. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13445. * @param radius The radius of the sphere to emit from
  13446. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13447. * @returns the emitter
  13448. */
  13449. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13450. /**
  13451. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13452. * @param radius The radius of the sphere to emit from
  13453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13455. * @returns the emitter
  13456. */
  13457. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13458. /**
  13459. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13460. * @param radius The radius of the emission cylinder
  13461. * @param height The height of the emission cylinder
  13462. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13463. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13464. * @returns the emitter
  13465. */
  13466. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13467. /**
  13468. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13469. * @param radius The radius of the cylinder to emit from
  13470. * @param height The height of the emission cylinder
  13471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13474. * @returns the emitter
  13475. */
  13476. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13477. /**
  13478. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13479. * @param radius The radius of the cone to emit from
  13480. * @param angle The base angle of the cone
  13481. * @returns the emitter
  13482. */
  13483. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13484. /**
  13485. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13488. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13489. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13490. * @returns the emitter
  13491. */
  13492. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13493. /**
  13494. * Get hosting scene
  13495. * @returns the scene
  13496. */
  13497. getScene(): Scene;
  13498. }
  13499. }
  13500. declare module BABYLON {
  13501. /**
  13502. * 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.
  13503. * @see https://doc.babylonjs.com/how_to/transformnode
  13504. */
  13505. export class TransformNode extends Node {
  13506. /**
  13507. * Object will not rotate to face the camera
  13508. */
  13509. static BILLBOARDMODE_NONE: number;
  13510. /**
  13511. * Object will rotate to face the camera but only on the x axis
  13512. */
  13513. static BILLBOARDMODE_X: number;
  13514. /**
  13515. * Object will rotate to face the camera but only on the y axis
  13516. */
  13517. static BILLBOARDMODE_Y: number;
  13518. /**
  13519. * Object will rotate to face the camera but only on the z axis
  13520. */
  13521. static BILLBOARDMODE_Z: number;
  13522. /**
  13523. * Object will rotate to face the camera
  13524. */
  13525. static BILLBOARDMODE_ALL: number;
  13526. /**
  13527. * Object will rotate to face the camera's position instead of orientation
  13528. */
  13529. static BILLBOARDMODE_USE_POSITION: number;
  13530. private _forward;
  13531. private _forwardInverted;
  13532. private _up;
  13533. private _right;
  13534. private _rightInverted;
  13535. private _position;
  13536. private _rotation;
  13537. private _rotationQuaternion;
  13538. protected _scaling: Vector3;
  13539. protected _isDirty: boolean;
  13540. private _transformToBoneReferal;
  13541. private _isAbsoluteSynced;
  13542. private _billboardMode;
  13543. /**
  13544. * Gets or sets the billboard mode. Default is 0.
  13545. *
  13546. * | Value | Type | Description |
  13547. * | --- | --- | --- |
  13548. * | 0 | BILLBOARDMODE_NONE | |
  13549. * | 1 | BILLBOARDMODE_X | |
  13550. * | 2 | BILLBOARDMODE_Y | |
  13551. * | 4 | BILLBOARDMODE_Z | |
  13552. * | 7 | BILLBOARDMODE_ALL | |
  13553. *
  13554. */
  13555. get billboardMode(): number;
  13556. set billboardMode(value: number);
  13557. private _preserveParentRotationForBillboard;
  13558. /**
  13559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13561. */
  13562. get preserveParentRotationForBillboard(): boolean;
  13563. set preserveParentRotationForBillboard(value: boolean);
  13564. /**
  13565. * 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
  13566. */
  13567. scalingDeterminant: number;
  13568. private _infiniteDistance;
  13569. /**
  13570. * Gets or sets the distance of the object to max, often used by skybox
  13571. */
  13572. get infiniteDistance(): boolean;
  13573. set infiniteDistance(value: boolean);
  13574. /**
  13575. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13576. * By default the system will update normals to compensate
  13577. */
  13578. ignoreNonUniformScaling: boolean;
  13579. /**
  13580. * 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
  13581. */
  13582. reIntegrateRotationIntoRotationQuaternion: boolean;
  13583. /** @hidden */
  13584. _poseMatrix: Nullable<Matrix>;
  13585. /** @hidden */
  13586. _localMatrix: Matrix;
  13587. private _usePivotMatrix;
  13588. private _absolutePosition;
  13589. private _absoluteScaling;
  13590. private _absoluteRotationQuaternion;
  13591. private _pivotMatrix;
  13592. private _pivotMatrixInverse;
  13593. protected _postMultiplyPivotMatrix: boolean;
  13594. protected _isWorldMatrixFrozen: boolean;
  13595. /** @hidden */
  13596. _indexInSceneTransformNodesArray: number;
  13597. /**
  13598. * An event triggered after the world matrix is updated
  13599. */
  13600. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13601. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13602. /**
  13603. * Gets a string identifying the name of the class
  13604. * @returns "TransformNode" string
  13605. */
  13606. getClassName(): string;
  13607. /**
  13608. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13609. */
  13610. get position(): Vector3;
  13611. set position(newPosition: Vector3);
  13612. /**
  13613. * 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)).
  13614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13615. */
  13616. get rotation(): Vector3;
  13617. set rotation(newRotation: Vector3);
  13618. /**
  13619. * 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)).
  13620. */
  13621. get scaling(): Vector3;
  13622. set scaling(newScaling: Vector3);
  13623. /**
  13624. * 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).
  13625. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13626. */
  13627. get rotationQuaternion(): Nullable<Quaternion>;
  13628. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13629. /**
  13630. * The forward direction of that transform in world space.
  13631. */
  13632. get forward(): Vector3;
  13633. /**
  13634. * The up direction of that transform in world space.
  13635. */
  13636. get up(): Vector3;
  13637. /**
  13638. * The right direction of that transform in world space.
  13639. */
  13640. get right(): Vector3;
  13641. /**
  13642. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13643. * @param matrix the matrix to copy the pose from
  13644. * @returns this TransformNode.
  13645. */
  13646. updatePoseMatrix(matrix: Matrix): TransformNode;
  13647. /**
  13648. * Returns the mesh Pose matrix.
  13649. * @returns the pose matrix
  13650. */
  13651. getPoseMatrix(): Matrix;
  13652. /** @hidden */
  13653. _isSynchronized(): boolean;
  13654. /** @hidden */
  13655. _initCache(): void;
  13656. /**
  13657. * Flag the transform node as dirty (Forcing it to update everything)
  13658. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13659. * @returns this transform node
  13660. */
  13661. markAsDirty(property: string): TransformNode;
  13662. /**
  13663. * Returns the current mesh absolute position.
  13664. * Returns a Vector3.
  13665. */
  13666. get absolutePosition(): Vector3;
  13667. /**
  13668. * Returns the current mesh absolute scaling.
  13669. * Returns a Vector3.
  13670. */
  13671. get absoluteScaling(): Vector3;
  13672. /**
  13673. * Returns the current mesh absolute rotation.
  13674. * Returns a Quaternion.
  13675. */
  13676. get absoluteRotationQuaternion(): Quaternion;
  13677. /**
  13678. * Sets a new matrix to apply before all other transformation
  13679. * @param matrix defines the transform matrix
  13680. * @returns the current TransformNode
  13681. */
  13682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13683. /**
  13684. * Sets a new pivot matrix to the current node
  13685. * @param matrix defines the new pivot matrix to use
  13686. * @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
  13687. * @returns the current TransformNode
  13688. */
  13689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13690. /**
  13691. * Returns the mesh pivot matrix.
  13692. * Default : Identity.
  13693. * @returns the matrix
  13694. */
  13695. getPivotMatrix(): Matrix;
  13696. /**
  13697. * Instantiate (when possible) or clone that node with its hierarchy
  13698. * @param newParent defines the new parent to use for the instance (or clone)
  13699. * @param options defines options to configure how copy is done
  13700. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13701. * @returns an instance (or a clone) of the current node with its hiearchy
  13702. */
  13703. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13704. doNotInstantiate: boolean;
  13705. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13706. /**
  13707. * Prevents the World matrix to be computed any longer
  13708. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13709. * @returns the TransformNode.
  13710. */
  13711. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13712. /**
  13713. * Allows back the World matrix computation.
  13714. * @returns the TransformNode.
  13715. */
  13716. unfreezeWorldMatrix(): this;
  13717. /**
  13718. * True if the World matrix has been frozen.
  13719. */
  13720. get isWorldMatrixFrozen(): boolean;
  13721. /**
  13722. * Retuns the mesh absolute position in the World.
  13723. * @returns a Vector3.
  13724. */
  13725. getAbsolutePosition(): Vector3;
  13726. /**
  13727. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13728. * @param absolutePosition the absolute position to set
  13729. * @returns the TransformNode.
  13730. */
  13731. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13732. /**
  13733. * Sets the mesh position in its local space.
  13734. * @param vector3 the position to set in localspace
  13735. * @returns the TransformNode.
  13736. */
  13737. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13738. /**
  13739. * Returns the mesh position in the local space from the current World matrix values.
  13740. * @returns a new Vector3.
  13741. */
  13742. getPositionExpressedInLocalSpace(): Vector3;
  13743. /**
  13744. * Translates the mesh along the passed Vector3 in its local space.
  13745. * @param vector3 the distance to translate in localspace
  13746. * @returns the TransformNode.
  13747. */
  13748. locallyTranslate(vector3: Vector3): TransformNode;
  13749. private static _lookAtVectorCache;
  13750. /**
  13751. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13752. * @param targetPoint the position (must be in same space as current mesh) to look at
  13753. * @param yawCor optional yaw (y-axis) correction in radians
  13754. * @param pitchCor optional pitch (x-axis) correction in radians
  13755. * @param rollCor optional roll (z-axis) correction in radians
  13756. * @param space the choosen space of the target
  13757. * @returns the TransformNode.
  13758. */
  13759. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13760. /**
  13761. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13762. * This Vector3 is expressed in the World space.
  13763. * @param localAxis axis to rotate
  13764. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13765. */
  13766. getDirection(localAxis: Vector3): Vector3;
  13767. /**
  13768. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13769. * localAxis is expressed in the mesh local space.
  13770. * result is computed in the Wordl space from the mesh World matrix.
  13771. * @param localAxis axis to rotate
  13772. * @param result the resulting transformnode
  13773. * @returns this TransformNode.
  13774. */
  13775. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13776. /**
  13777. * Sets this transform node rotation to the given local axis.
  13778. * @param localAxis the axis in local space
  13779. * @param yawCor optional yaw (y-axis) correction in radians
  13780. * @param pitchCor optional pitch (x-axis) correction in radians
  13781. * @param rollCor optional roll (z-axis) correction in radians
  13782. * @returns this TransformNode
  13783. */
  13784. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13785. /**
  13786. * Sets a new pivot point to the current node
  13787. * @param point defines the new pivot point to use
  13788. * @param space defines if the point is in world or local space (local by default)
  13789. * @returns the current TransformNode
  13790. */
  13791. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13792. /**
  13793. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13794. * @returns the pivot point
  13795. */
  13796. getPivotPoint(): Vector3;
  13797. /**
  13798. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13799. * @param result the vector3 to store the result
  13800. * @returns this TransformNode.
  13801. */
  13802. getPivotPointToRef(result: Vector3): TransformNode;
  13803. /**
  13804. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13805. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13806. */
  13807. getAbsolutePivotPoint(): Vector3;
  13808. /**
  13809. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13810. * @param result vector3 to store the result
  13811. * @returns this TransformNode.
  13812. */
  13813. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13814. /**
  13815. * Defines the passed node as the parent of the current node.
  13816. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13817. * @see https://doc.babylonjs.com/how_to/parenting
  13818. * @param node the node ot set as the parent
  13819. * @returns this TransformNode.
  13820. */
  13821. setParent(node: Nullable<Node>): TransformNode;
  13822. private _nonUniformScaling;
  13823. /**
  13824. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13825. */
  13826. get nonUniformScaling(): boolean;
  13827. /** @hidden */
  13828. _updateNonUniformScalingState(value: boolean): boolean;
  13829. /**
  13830. * Attach the current TransformNode to another TransformNode associated with a bone
  13831. * @param bone Bone affecting the TransformNode
  13832. * @param affectedTransformNode TransformNode associated with the bone
  13833. * @returns this object
  13834. */
  13835. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13836. /**
  13837. * Detach the transform node if its associated with a bone
  13838. * @returns this object
  13839. */
  13840. detachFromBone(): TransformNode;
  13841. private static _rotationAxisCache;
  13842. /**
  13843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13844. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13845. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13846. * The passed axis is also normalized.
  13847. * @param axis the axis to rotate around
  13848. * @param amount the amount to rotate in radians
  13849. * @param space Space to rotate in (Default: local)
  13850. * @returns the TransformNode.
  13851. */
  13852. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13853. /**
  13854. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13855. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13856. * The passed axis is also normalized. .
  13857. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13858. * @param point the point to rotate around
  13859. * @param axis the axis to rotate around
  13860. * @param amount the amount to rotate in radians
  13861. * @returns the TransformNode
  13862. */
  13863. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13864. /**
  13865. * Translates the mesh along the axis vector for the passed distance in the given space.
  13866. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13867. * @param axis the axis to translate in
  13868. * @param distance the distance to translate
  13869. * @param space Space to rotate in (Default: local)
  13870. * @returns the TransformNode.
  13871. */
  13872. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13873. /**
  13874. * Adds a rotation step to the mesh current rotation.
  13875. * x, y, z are Euler angles expressed in radians.
  13876. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13877. * This means this rotation is made in the mesh local space only.
  13878. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13879. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13880. * ```javascript
  13881. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13882. * ```
  13883. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13884. * 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.
  13885. * @param x Rotation to add
  13886. * @param y Rotation to add
  13887. * @param z Rotation to add
  13888. * @returns the TransformNode.
  13889. */
  13890. addRotation(x: number, y: number, z: number): TransformNode;
  13891. /**
  13892. * @hidden
  13893. */
  13894. protected _getEffectiveParent(): Nullable<Node>;
  13895. /**
  13896. * Computes the world matrix of the node
  13897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13898. * @returns the world matrix
  13899. */
  13900. computeWorldMatrix(force?: boolean): Matrix;
  13901. /**
  13902. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13903. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13904. */
  13905. resetLocalMatrix(independentOfChildren?: boolean): void;
  13906. protected _afterComputeWorldMatrix(): void;
  13907. /**
  13908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13909. * @param func callback function to add
  13910. *
  13911. * @returns the TransformNode.
  13912. */
  13913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13914. /**
  13915. * Removes a registered callback function.
  13916. * @param func callback function to remove
  13917. * @returns the TransformNode.
  13918. */
  13919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13920. /**
  13921. * Gets the position of the current mesh in camera space
  13922. * @param camera defines the camera to use
  13923. * @returns a position
  13924. */
  13925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13926. /**
  13927. * Returns the distance from the mesh to the active camera
  13928. * @param camera defines the camera to use
  13929. * @returns the distance
  13930. */
  13931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13932. /**
  13933. * Clone the current transform node
  13934. * @param name Name of the new clone
  13935. * @param newParent New parent for the clone
  13936. * @param doNotCloneChildren Do not clone children hierarchy
  13937. * @returns the new transform node
  13938. */
  13939. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13940. /**
  13941. * Serializes the objects information.
  13942. * @param currentSerializationObject defines the object to serialize in
  13943. * @returns the serialized object
  13944. */
  13945. serialize(currentSerializationObject?: any): any;
  13946. /**
  13947. * Returns a new TransformNode object parsed from the source provided.
  13948. * @param parsedTransformNode is the source.
  13949. * @param scene the scne the object belongs to
  13950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13951. * @returns a new TransformNode object parsed from the source provided.
  13952. */
  13953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13954. /**
  13955. * Get all child-transformNodes of this node
  13956. * @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
  13957. * @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
  13958. * @returns an array of TransformNode
  13959. */
  13960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13961. /**
  13962. * Releases resources associated with this transform node.
  13963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13965. */
  13966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13967. /**
  13968. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13969. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13970. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13971. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13972. * @returns the current mesh
  13973. */
  13974. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13975. private _syncAbsoluteScalingAndRotation;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. /**
  13980. * Class used to override all child animations of a given target
  13981. */
  13982. export class AnimationPropertiesOverride {
  13983. /**
  13984. * Gets or sets a value indicating if animation blending must be used
  13985. */
  13986. enableBlending: boolean;
  13987. /**
  13988. * Gets or sets the blending speed to use when enableBlending is true
  13989. */
  13990. blendingSpeed: number;
  13991. /**
  13992. * Gets or sets the default loop mode to use
  13993. */
  13994. loopMode: number;
  13995. }
  13996. }
  13997. declare module BABYLON {
  13998. /**
  13999. * Class used to store bone information
  14000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14001. */
  14002. export class Bone extends Node {
  14003. /**
  14004. * defines the bone name
  14005. */
  14006. name: string;
  14007. private static _tmpVecs;
  14008. private static _tmpQuat;
  14009. private static _tmpMats;
  14010. /**
  14011. * Gets the list of child bones
  14012. */
  14013. children: Bone[];
  14014. /** Gets the animations associated with this bone */
  14015. animations: Animation[];
  14016. /**
  14017. * Gets or sets bone length
  14018. */
  14019. length: number;
  14020. /**
  14021. * @hidden Internal only
  14022. * Set this value to map this bone to a different index in the transform matrices
  14023. * Set this value to -1 to exclude the bone from the transform matrices
  14024. */
  14025. _index: Nullable<number>;
  14026. private _skeleton;
  14027. private _localMatrix;
  14028. private _restPose;
  14029. private _baseMatrix;
  14030. private _absoluteTransform;
  14031. private _invertedAbsoluteTransform;
  14032. private _parent;
  14033. private _scalingDeterminant;
  14034. private _worldTransform;
  14035. private _localScaling;
  14036. private _localRotation;
  14037. private _localPosition;
  14038. private _needToDecompose;
  14039. private _needToCompose;
  14040. /** @hidden */
  14041. _linkedTransformNode: Nullable<TransformNode>;
  14042. /** @hidden */
  14043. _waitingTransformNodeId: Nullable<string>;
  14044. /** @hidden */
  14045. get _matrix(): Matrix;
  14046. /** @hidden */
  14047. set _matrix(value: Matrix);
  14048. /**
  14049. * Create a new bone
  14050. * @param name defines the bone name
  14051. * @param skeleton defines the parent skeleton
  14052. * @param parentBone defines the parent (can be null if the bone is the root)
  14053. * @param localMatrix defines the local matrix
  14054. * @param restPose defines the rest pose matrix
  14055. * @param baseMatrix defines the base matrix
  14056. * @param index defines index of the bone in the hiearchy
  14057. */
  14058. constructor(
  14059. /**
  14060. * defines the bone name
  14061. */
  14062. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14063. /**
  14064. * Gets the current object class name.
  14065. * @return the class name
  14066. */
  14067. getClassName(): string;
  14068. /**
  14069. * Gets the parent skeleton
  14070. * @returns a skeleton
  14071. */
  14072. getSkeleton(): Skeleton;
  14073. /**
  14074. * Gets parent bone
  14075. * @returns a bone or null if the bone is the root of the bone hierarchy
  14076. */
  14077. getParent(): Nullable<Bone>;
  14078. /**
  14079. * Returns an array containing the root bones
  14080. * @returns an array containing the root bones
  14081. */
  14082. getChildren(): Array<Bone>;
  14083. /**
  14084. * Gets the node index in matrix array generated for rendering
  14085. * @returns the node index
  14086. */
  14087. getIndex(): number;
  14088. /**
  14089. * Sets the parent bone
  14090. * @param parent defines the parent (can be null if the bone is the root)
  14091. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14092. */
  14093. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14094. /**
  14095. * Gets the local matrix
  14096. * @returns a matrix
  14097. */
  14098. getLocalMatrix(): Matrix;
  14099. /**
  14100. * Gets the base matrix (initial matrix which remains unchanged)
  14101. * @returns a matrix
  14102. */
  14103. getBaseMatrix(): Matrix;
  14104. /**
  14105. * Gets the rest pose matrix
  14106. * @returns a matrix
  14107. */
  14108. getRestPose(): Matrix;
  14109. /**
  14110. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14111. */
  14112. getWorldMatrix(): Matrix;
  14113. /**
  14114. * Sets the local matrix to rest pose matrix
  14115. */
  14116. returnToRest(): void;
  14117. /**
  14118. * Gets the inverse of the absolute transform matrix.
  14119. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14120. * @returns a matrix
  14121. */
  14122. getInvertedAbsoluteTransform(): Matrix;
  14123. /**
  14124. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14125. * @returns a matrix
  14126. */
  14127. getAbsoluteTransform(): Matrix;
  14128. /**
  14129. * Links with the given transform node.
  14130. * The local matrix of this bone is copied from the transform node every frame.
  14131. * @param transformNode defines the transform node to link to
  14132. */
  14133. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14134. /**
  14135. * Gets the node used to drive the bone's transformation
  14136. * @returns a transform node or null
  14137. */
  14138. getTransformNode(): Nullable<TransformNode>;
  14139. /** Gets or sets current position (in local space) */
  14140. get position(): Vector3;
  14141. set position(newPosition: Vector3);
  14142. /** Gets or sets current rotation (in local space) */
  14143. get rotation(): Vector3;
  14144. set rotation(newRotation: Vector3);
  14145. /** Gets or sets current rotation quaternion (in local space) */
  14146. get rotationQuaternion(): Quaternion;
  14147. set rotationQuaternion(newRotation: Quaternion);
  14148. /** Gets or sets current scaling (in local space) */
  14149. get scaling(): Vector3;
  14150. set scaling(newScaling: Vector3);
  14151. /**
  14152. * Gets the animation properties override
  14153. */
  14154. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14155. private _decompose;
  14156. private _compose;
  14157. /**
  14158. * Update the base and local matrices
  14159. * @param matrix defines the new base or local matrix
  14160. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14161. * @param updateLocalMatrix defines if the local matrix should be updated
  14162. */
  14163. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14164. /** @hidden */
  14165. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14166. /**
  14167. * Flag the bone as dirty (Forcing it to update everything)
  14168. */
  14169. markAsDirty(): void;
  14170. /** @hidden */
  14171. _markAsDirtyAndCompose(): void;
  14172. private _markAsDirtyAndDecompose;
  14173. /**
  14174. * Translate the bone in local or world space
  14175. * @param vec The amount to translate the bone
  14176. * @param space The space that the translation is in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. */
  14179. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14180. /**
  14181. * Set the postion of the bone in local or world space
  14182. * @param position The position to set the bone
  14183. * @param space The space that the position is in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. */
  14186. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14187. /**
  14188. * Set the absolute position of the bone (world space)
  14189. * @param position The position to set the bone
  14190. * @param mesh The mesh that this bone is attached to
  14191. */
  14192. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14193. /**
  14194. * Scale the bone on the x, y and z axes (in local space)
  14195. * @param x The amount to scale the bone on the x axis
  14196. * @param y The amount to scale the bone on the y axis
  14197. * @param z The amount to scale the bone on the z axis
  14198. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14199. */
  14200. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14201. /**
  14202. * Set the bone scaling in local space
  14203. * @param scale defines the scaling vector
  14204. */
  14205. setScale(scale: Vector3): void;
  14206. /**
  14207. * Gets the current scaling in local space
  14208. * @returns the current scaling vector
  14209. */
  14210. getScale(): Vector3;
  14211. /**
  14212. * Gets the current scaling in local space and stores it in a target vector
  14213. * @param result defines the target vector
  14214. */
  14215. getScaleToRef(result: Vector3): void;
  14216. /**
  14217. * Set the yaw, pitch, and roll of the bone in local or world space
  14218. * @param yaw The rotation of the bone on the y axis
  14219. * @param pitch The rotation of the bone on the x axis
  14220. * @param roll The rotation of the bone on the z axis
  14221. * @param space The space that the axes of rotation are in
  14222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14223. */
  14224. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14225. /**
  14226. * Add a rotation to the bone on an axis in local or world space
  14227. * @param axis The axis to rotate the bone on
  14228. * @param amount The amount to rotate the bone
  14229. * @param space The space that the axis is in
  14230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14231. */
  14232. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14233. /**
  14234. * Set the rotation of the bone to a particular axis angle in local or world space
  14235. * @param axis The axis to rotate the bone on
  14236. * @param angle The angle that the bone should be rotated to
  14237. * @param space The space that the axis is in
  14238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14239. */
  14240. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14241. /**
  14242. * Set the euler rotation of the bone in local of world space
  14243. * @param rotation The euler rotation that the bone should be set to
  14244. * @param space The space that the rotation is in
  14245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14246. */
  14247. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14248. /**
  14249. * Set the quaternion rotation of the bone in local of world space
  14250. * @param quat The quaternion rotation that the bone should be set to
  14251. * @param space The space that the rotation is in
  14252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14253. */
  14254. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14255. /**
  14256. * Set the rotation matrix of the bone in local of world space
  14257. * @param rotMat The rotation matrix that the bone should be set to
  14258. * @param space The space that the rotation is in
  14259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14260. */
  14261. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14262. private _rotateWithMatrix;
  14263. private _getNegativeRotationToRef;
  14264. /**
  14265. * Get the position of the bone in local or world space
  14266. * @param space The space that the returned position is in
  14267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14268. * @returns The position of the bone
  14269. */
  14270. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14271. /**
  14272. * Copy the position of the bone to a vector3 in local or world space
  14273. * @param space The space that the returned position is in
  14274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14275. * @param result The vector3 to copy the position to
  14276. */
  14277. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14278. /**
  14279. * Get the absolute position of the bone (world space)
  14280. * @param mesh The mesh that this bone is attached to
  14281. * @returns The absolute position of the bone
  14282. */
  14283. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14284. /**
  14285. * Copy the absolute position of the bone (world space) to the result param
  14286. * @param mesh The mesh that this bone is attached to
  14287. * @param result The vector3 to copy the absolute position to
  14288. */
  14289. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14290. /**
  14291. * Compute the absolute transforms of this bone and its children
  14292. */
  14293. computeAbsoluteTransforms(): void;
  14294. /**
  14295. * Get the world direction from an axis that is in the local space of the bone
  14296. * @param localAxis The local direction that is used to compute the world direction
  14297. * @param mesh The mesh that this bone is attached to
  14298. * @returns The world direction
  14299. */
  14300. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14301. /**
  14302. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14303. * @param localAxis The local direction that is used to compute the world direction
  14304. * @param mesh The mesh that this bone is attached to
  14305. * @param result The vector3 that the world direction will be copied to
  14306. */
  14307. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14308. /**
  14309. * Get the euler rotation of the bone in local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @returns The euler rotation
  14313. */
  14314. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14317. * @param space The space that the rotation should be in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. * @param result The vector3 that the rotation should be copied to
  14320. */
  14321. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the quaternion rotation of the bone in either local or world space
  14324. * @param space The space that the rotation should be in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. * @returns The quaternion rotation
  14327. */
  14328. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14329. /**
  14330. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14331. * @param space The space that the rotation should be in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. * @param result The quaternion that the rotation should be copied to
  14334. */
  14335. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14336. /**
  14337. * Get the rotation matrix of the bone in local or world space
  14338. * @param space The space that the rotation should be in
  14339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14340. * @returns The rotation matrix
  14341. */
  14342. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14343. /**
  14344. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14345. * @param space The space that the rotation should be in
  14346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14347. * @param result The quaternion that the rotation should be copied to
  14348. */
  14349. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14350. /**
  14351. * Get the world position of a point that is in the local space of the bone
  14352. * @param position The local position
  14353. * @param mesh The mesh that this bone is attached to
  14354. * @returns The world position
  14355. */
  14356. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14357. /**
  14358. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14359. * @param position The local position
  14360. * @param mesh The mesh that this bone is attached to
  14361. * @param result The vector3 that the world position should be copied to
  14362. */
  14363. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14364. /**
  14365. * Get the local position of a point that is in world space
  14366. * @param position The world position
  14367. * @param mesh The mesh that this bone is attached to
  14368. * @returns The local position
  14369. */
  14370. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14371. /**
  14372. * Get the local position of a point that is in world space and copy it to the result param
  14373. * @param position The world position
  14374. * @param mesh The mesh that this bone is attached to
  14375. * @param result The vector3 that the local position should be copied to
  14376. */
  14377. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14378. }
  14379. }
  14380. declare module BABYLON {
  14381. /**
  14382. * Defines a runtime animation
  14383. */
  14384. export class RuntimeAnimation {
  14385. private _events;
  14386. /**
  14387. * The current frame of the runtime animation
  14388. */
  14389. private _currentFrame;
  14390. /**
  14391. * The animation used by the runtime animation
  14392. */
  14393. private _animation;
  14394. /**
  14395. * The target of the runtime animation
  14396. */
  14397. private _target;
  14398. /**
  14399. * The initiating animatable
  14400. */
  14401. private _host;
  14402. /**
  14403. * The original value of the runtime animation
  14404. */
  14405. private _originalValue;
  14406. /**
  14407. * The original blend value of the runtime animation
  14408. */
  14409. private _originalBlendValue;
  14410. /**
  14411. * The offsets cache of the runtime animation
  14412. */
  14413. private _offsetsCache;
  14414. /**
  14415. * The high limits cache of the runtime animation
  14416. */
  14417. private _highLimitsCache;
  14418. /**
  14419. * Specifies if the runtime animation has been stopped
  14420. */
  14421. private _stopped;
  14422. /**
  14423. * The blending factor of the runtime animation
  14424. */
  14425. private _blendingFactor;
  14426. /**
  14427. * The BabylonJS scene
  14428. */
  14429. private _scene;
  14430. /**
  14431. * The current value of the runtime animation
  14432. */
  14433. private _currentValue;
  14434. /** @hidden */
  14435. _animationState: _IAnimationState;
  14436. /**
  14437. * The active target of the runtime animation
  14438. */
  14439. private _activeTargets;
  14440. private _currentActiveTarget;
  14441. private _directTarget;
  14442. /**
  14443. * The target path of the runtime animation
  14444. */
  14445. private _targetPath;
  14446. /**
  14447. * The weight of the runtime animation
  14448. */
  14449. private _weight;
  14450. /**
  14451. * The ratio offset of the runtime animation
  14452. */
  14453. private _ratioOffset;
  14454. /**
  14455. * The previous delay of the runtime animation
  14456. */
  14457. private _previousDelay;
  14458. /**
  14459. * The previous ratio of the runtime animation
  14460. */
  14461. private _previousRatio;
  14462. private _enableBlending;
  14463. private _keys;
  14464. private _minFrame;
  14465. private _maxFrame;
  14466. private _minValue;
  14467. private _maxValue;
  14468. private _targetIsArray;
  14469. /**
  14470. * Gets the current frame of the runtime animation
  14471. */
  14472. get currentFrame(): number;
  14473. /**
  14474. * Gets the weight of the runtime animation
  14475. */
  14476. get weight(): number;
  14477. /**
  14478. * Gets the current value of the runtime animation
  14479. */
  14480. get currentValue(): any;
  14481. /**
  14482. * Gets the target path of the runtime animation
  14483. */
  14484. get targetPath(): string;
  14485. /**
  14486. * Gets the actual target of the runtime animation
  14487. */
  14488. get target(): any;
  14489. /** @hidden */
  14490. _onLoop: () => void;
  14491. /**
  14492. * Create a new RuntimeAnimation object
  14493. * @param target defines the target of the animation
  14494. * @param animation defines the source animation object
  14495. * @param scene defines the hosting scene
  14496. * @param host defines the initiating Animatable
  14497. */
  14498. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14499. private _preparePath;
  14500. /**
  14501. * Gets the animation from the runtime animation
  14502. */
  14503. get animation(): Animation;
  14504. /**
  14505. * Resets the runtime animation to the beginning
  14506. * @param restoreOriginal defines whether to restore the target property to the original value
  14507. */
  14508. reset(restoreOriginal?: boolean): void;
  14509. /**
  14510. * Specifies if the runtime animation is stopped
  14511. * @returns Boolean specifying if the runtime animation is stopped
  14512. */
  14513. isStopped(): boolean;
  14514. /**
  14515. * Disposes of the runtime animation
  14516. */
  14517. dispose(): void;
  14518. /**
  14519. * Apply the interpolated value to the target
  14520. * @param currentValue defines the value computed by the animation
  14521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14522. */
  14523. setValue(currentValue: any, weight: number): void;
  14524. private _getOriginalValues;
  14525. private _setValue;
  14526. /**
  14527. * Gets the loop pmode of the runtime animation
  14528. * @returns Loop Mode
  14529. */
  14530. private _getCorrectLoopMode;
  14531. /**
  14532. * Move the current animation to a given frame
  14533. * @param frame defines the frame to move to
  14534. */
  14535. goToFrame(frame: number): void;
  14536. /**
  14537. * @hidden Internal use only
  14538. */
  14539. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14540. /**
  14541. * Execute the current animation
  14542. * @param delay defines the delay to add to the current frame
  14543. * @param from defines the lower bound of the animation range
  14544. * @param to defines the upper bound of the animation range
  14545. * @param loop defines if the current animation must loop
  14546. * @param speedRatio defines the current speed ratio
  14547. * @param weight defines the weight of the animation (default is -1 so no weight)
  14548. * @param onLoop optional callback called when animation loops
  14549. * @returns a boolean indicating if the animation is running
  14550. */
  14551. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Class used to store an actual running animation
  14557. */
  14558. export class Animatable {
  14559. /** defines the target object */
  14560. target: any;
  14561. /** defines the starting frame number (default is 0) */
  14562. fromFrame: number;
  14563. /** defines the ending frame number (default is 100) */
  14564. toFrame: number;
  14565. /** defines if the animation must loop (default is false) */
  14566. loopAnimation: boolean;
  14567. /** defines a callback to call when animation ends if it is not looping */
  14568. onAnimationEnd?: (() => void) | null | undefined;
  14569. /** defines a callback to call when animation loops */
  14570. onAnimationLoop?: (() => void) | null | undefined;
  14571. private _localDelayOffset;
  14572. private _pausedDelay;
  14573. private _runtimeAnimations;
  14574. private _paused;
  14575. private _scene;
  14576. private _speedRatio;
  14577. private _weight;
  14578. private _syncRoot;
  14579. /**
  14580. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14581. * This will only apply for non looping animation (default is true)
  14582. */
  14583. disposeOnEnd: boolean;
  14584. /**
  14585. * Gets a boolean indicating if the animation has started
  14586. */
  14587. animationStarted: boolean;
  14588. /**
  14589. * Observer raised when the animation ends
  14590. */
  14591. onAnimationEndObservable: Observable<Animatable>;
  14592. /**
  14593. * Observer raised when the animation loops
  14594. */
  14595. onAnimationLoopObservable: Observable<Animatable>;
  14596. /**
  14597. * Gets the root Animatable used to synchronize and normalize animations
  14598. */
  14599. get syncRoot(): Nullable<Animatable>;
  14600. /**
  14601. * Gets the current frame of the first RuntimeAnimation
  14602. * Used to synchronize Animatables
  14603. */
  14604. get masterFrame(): number;
  14605. /**
  14606. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14607. */
  14608. get weight(): number;
  14609. set weight(value: number);
  14610. /**
  14611. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14612. */
  14613. get speedRatio(): number;
  14614. set speedRatio(value: number);
  14615. /**
  14616. * Creates a new Animatable
  14617. * @param scene defines the hosting scene
  14618. * @param target defines the target object
  14619. * @param fromFrame defines the starting frame number (default is 0)
  14620. * @param toFrame defines the ending frame number (default is 100)
  14621. * @param loopAnimation defines if the animation must loop (default is false)
  14622. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14623. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14624. * @param animations defines a group of animation to add to the new Animatable
  14625. * @param onAnimationLoop defines a callback to call when animation loops
  14626. */
  14627. constructor(scene: Scene,
  14628. /** defines the target object */
  14629. target: any,
  14630. /** defines the starting frame number (default is 0) */
  14631. fromFrame?: number,
  14632. /** defines the ending frame number (default is 100) */
  14633. toFrame?: number,
  14634. /** defines if the animation must loop (default is false) */
  14635. loopAnimation?: boolean, speedRatio?: number,
  14636. /** defines a callback to call when animation ends if it is not looping */
  14637. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14638. /** defines a callback to call when animation loops */
  14639. onAnimationLoop?: (() => void) | null | undefined);
  14640. /**
  14641. * Synchronize and normalize current Animatable with a source Animatable
  14642. * This is useful when using animation weights and when animations are not of the same length
  14643. * @param root defines the root Animatable to synchronize with
  14644. * @returns the current Animatable
  14645. */
  14646. syncWith(root: Animatable): Animatable;
  14647. /**
  14648. * Gets the list of runtime animations
  14649. * @returns an array of RuntimeAnimation
  14650. */
  14651. getAnimations(): RuntimeAnimation[];
  14652. /**
  14653. * Adds more animations to the current animatable
  14654. * @param target defines the target of the animations
  14655. * @param animations defines the new animations to add
  14656. */
  14657. appendAnimations(target: any, animations: Animation[]): void;
  14658. /**
  14659. * Gets the source animation for a specific property
  14660. * @param property defines the propertyu to look for
  14661. * @returns null or the source animation for the given property
  14662. */
  14663. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14664. /**
  14665. * Gets the runtime animation for a specific property
  14666. * @param property defines the propertyu to look for
  14667. * @returns null or the runtime animation for the given property
  14668. */
  14669. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14670. /**
  14671. * Resets the animatable to its original state
  14672. */
  14673. reset(): void;
  14674. /**
  14675. * Allows the animatable to blend with current running animations
  14676. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14677. * @param blendingSpeed defines the blending speed to use
  14678. */
  14679. enableBlending(blendingSpeed: number): void;
  14680. /**
  14681. * Disable animation blending
  14682. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14683. */
  14684. disableBlending(): void;
  14685. /**
  14686. * Jump directly to a given frame
  14687. * @param frame defines the frame to jump to
  14688. */
  14689. goToFrame(frame: number): void;
  14690. /**
  14691. * Pause the animation
  14692. */
  14693. pause(): void;
  14694. /**
  14695. * Restart the animation
  14696. */
  14697. restart(): void;
  14698. private _raiseOnAnimationEnd;
  14699. /**
  14700. * Stop and delete the current animation
  14701. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14702. * @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)
  14703. */
  14704. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14705. /**
  14706. * Wait asynchronously for the animation to end
  14707. * @returns a promise which will be fullfilled when the animation ends
  14708. */
  14709. waitAsync(): Promise<Animatable>;
  14710. /** @hidden */
  14711. _animate(delay: number): boolean;
  14712. }
  14713. interface Scene {
  14714. /** @hidden */
  14715. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14716. /** @hidden */
  14717. _processLateAnimationBindingsForMatrices(holder: {
  14718. totalWeight: number;
  14719. animations: RuntimeAnimation[];
  14720. originalValue: Matrix;
  14721. }): any;
  14722. /** @hidden */
  14723. _processLateAnimationBindingsForQuaternions(holder: {
  14724. totalWeight: number;
  14725. animations: RuntimeAnimation[];
  14726. originalValue: Quaternion;
  14727. }, refQuaternion: Quaternion): Quaternion;
  14728. /** @hidden */
  14729. _processLateAnimationBindings(): void;
  14730. /**
  14731. * Will start the animation sequence of a given target
  14732. * @param target defines the target
  14733. * @param from defines from which frame should animation start
  14734. * @param to defines until which frame should animation run.
  14735. * @param weight defines the weight to apply to the animation (1.0 by default)
  14736. * @param loop defines if the animation loops
  14737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14738. * @param onAnimationEnd defines the function to be executed when the animation ends
  14739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14741. * @param onAnimationLoop defines the callback to call when an animation loops
  14742. * @returns the animatable object created for this animation
  14743. */
  14744. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14745. /**
  14746. * Will start the animation sequence of a given target
  14747. * @param target defines the target
  14748. * @param from defines from which frame should animation start
  14749. * @param to defines until which frame should animation run.
  14750. * @param loop defines if the animation loops
  14751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14752. * @param onAnimationEnd defines the function to be executed when the animation ends
  14753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14754. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14755. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14756. * @param onAnimationLoop defines the callback to call when an animation loops
  14757. * @returns the animatable object created for this animation
  14758. */
  14759. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14760. /**
  14761. * Will start the animation sequence of a given target and its hierarchy
  14762. * @param target defines the target
  14763. * @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.
  14764. * @param from defines from which frame should animation start
  14765. * @param to defines until which frame should animation run.
  14766. * @param loop defines if the animation loops
  14767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14768. * @param onAnimationEnd defines the function to be executed when the animation ends
  14769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14770. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14772. * @param onAnimationLoop defines the callback to call when an animation loops
  14773. * @returns the list of created animatables
  14774. */
  14775. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  14776. /**
  14777. * Begin a new animation on a given node
  14778. * @param target defines the target where the animation will take place
  14779. * @param animations defines the list of animations to start
  14780. * @param from defines the initial value
  14781. * @param to defines the final value
  14782. * @param loop defines if you want animation to loop (off by default)
  14783. * @param speedRatio defines the speed ratio to apply to all animations
  14784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14785. * @param onAnimationLoop defines the callback to call when an animation loops
  14786. * @returns the list of created animatables
  14787. */
  14788. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14789. /**
  14790. * Begin a new animation on a given node and its hierarchy
  14791. * @param target defines the root node where the animation will take place
  14792. * @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.
  14793. * @param animations defines the list of animations to start
  14794. * @param from defines the initial value
  14795. * @param to defines the final value
  14796. * @param loop defines if you want animation to loop (off by default)
  14797. * @param speedRatio defines the speed ratio to apply to all animations
  14798. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14799. * @param onAnimationLoop defines the callback to call when an animation loops
  14800. * @returns the list of animatables created for all nodes
  14801. */
  14802. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14803. /**
  14804. * Gets the animatable associated with a specific target
  14805. * @param target defines the target of the animatable
  14806. * @returns the required animatable if found
  14807. */
  14808. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14809. /**
  14810. * Gets all animatables associated with a given target
  14811. * @param target defines the target to look animatables for
  14812. * @returns an array of Animatables
  14813. */
  14814. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14815. /**
  14816. * Stops and removes all animations that have been applied to the scene
  14817. */
  14818. stopAllAnimations(): void;
  14819. /**
  14820. * Gets the current delta time used by animation engine
  14821. */
  14822. deltaTime: number;
  14823. }
  14824. interface Bone {
  14825. /**
  14826. * Copy an animation range from another bone
  14827. * @param source defines the source bone
  14828. * @param rangeName defines the range name to copy
  14829. * @param frameOffset defines the frame offset
  14830. * @param rescaleAsRequired defines if rescaling must be applied if required
  14831. * @param skelDimensionsRatio defines the scaling ratio
  14832. * @returns true if operation was successful
  14833. */
  14834. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14835. }
  14836. }
  14837. declare module BABYLON {
  14838. /**
  14839. * Class used to handle skinning animations
  14840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14841. */
  14842. export class Skeleton implements IAnimatable {
  14843. /** defines the skeleton name */
  14844. name: string;
  14845. /** defines the skeleton Id */
  14846. id: string;
  14847. /**
  14848. * Defines the list of child bones
  14849. */
  14850. bones: Bone[];
  14851. /**
  14852. * Defines an estimate of the dimension of the skeleton at rest
  14853. */
  14854. dimensionsAtRest: Vector3;
  14855. /**
  14856. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14857. */
  14858. needInitialSkinMatrix: boolean;
  14859. /**
  14860. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14861. */
  14862. overrideMesh: Nullable<AbstractMesh>;
  14863. /**
  14864. * Gets the list of animations attached to this skeleton
  14865. */
  14866. animations: Array<Animation>;
  14867. private _scene;
  14868. private _isDirty;
  14869. private _transformMatrices;
  14870. private _transformMatrixTexture;
  14871. private _meshesWithPoseMatrix;
  14872. private _animatables;
  14873. private _identity;
  14874. private _synchronizedWithMesh;
  14875. private _ranges;
  14876. private _lastAbsoluteTransformsUpdateId;
  14877. private _canUseTextureForBones;
  14878. private _uniqueId;
  14879. /** @hidden */
  14880. _numBonesWithLinkedTransformNode: number;
  14881. /** @hidden */
  14882. _hasWaitingData: Nullable<boolean>;
  14883. /**
  14884. * Specifies if the skeleton should be serialized
  14885. */
  14886. doNotSerialize: boolean;
  14887. private _useTextureToStoreBoneMatrices;
  14888. /**
  14889. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14890. * Please note that this option is not available if the hardware does not support it
  14891. */
  14892. get useTextureToStoreBoneMatrices(): boolean;
  14893. set useTextureToStoreBoneMatrices(value: boolean);
  14894. private _animationPropertiesOverride;
  14895. /**
  14896. * Gets or sets the animation properties override
  14897. */
  14898. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14899. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14900. /**
  14901. * List of inspectable custom properties (used by the Inspector)
  14902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14903. */
  14904. inspectableCustomProperties: IInspectable[];
  14905. /**
  14906. * An observable triggered before computing the skeleton's matrices
  14907. */
  14908. onBeforeComputeObservable: Observable<Skeleton>;
  14909. /**
  14910. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14911. */
  14912. get isUsingTextureForMatrices(): boolean;
  14913. /**
  14914. * Gets the unique ID of this skeleton
  14915. */
  14916. get uniqueId(): number;
  14917. /**
  14918. * Creates a new skeleton
  14919. * @param name defines the skeleton name
  14920. * @param id defines the skeleton Id
  14921. * @param scene defines the hosting scene
  14922. */
  14923. constructor(
  14924. /** defines the skeleton name */
  14925. name: string,
  14926. /** defines the skeleton Id */
  14927. id: string, scene: Scene);
  14928. /**
  14929. * Gets the current object class name.
  14930. * @return the class name
  14931. */
  14932. getClassName(): string;
  14933. /**
  14934. * Returns an array containing the root bones
  14935. * @returns an array containing the root bones
  14936. */
  14937. getChildren(): Array<Bone>;
  14938. /**
  14939. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14940. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14941. * @returns a Float32Array containing matrices data
  14942. */
  14943. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14944. /**
  14945. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14946. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14947. * @returns a raw texture containing the data
  14948. */
  14949. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14950. /**
  14951. * Gets the current hosting scene
  14952. * @returns a scene object
  14953. */
  14954. getScene(): Scene;
  14955. /**
  14956. * Gets a string representing the current skeleton data
  14957. * @param fullDetails defines a boolean indicating if we want a verbose version
  14958. * @returns a string representing the current skeleton data
  14959. */
  14960. toString(fullDetails?: boolean): string;
  14961. /**
  14962. * Get bone's index searching by name
  14963. * @param name defines bone's name to search for
  14964. * @return the indice of the bone. Returns -1 if not found
  14965. */
  14966. getBoneIndexByName(name: string): number;
  14967. /**
  14968. * Creater a new animation range
  14969. * @param name defines the name of the range
  14970. * @param from defines the start key
  14971. * @param to defines the end key
  14972. */
  14973. createAnimationRange(name: string, from: number, to: number): void;
  14974. /**
  14975. * Delete a specific animation range
  14976. * @param name defines the name of the range
  14977. * @param deleteFrames defines if frames must be removed as well
  14978. */
  14979. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14980. /**
  14981. * Gets a specific animation range
  14982. * @param name defines the name of the range to look for
  14983. * @returns the requested animation range or null if not found
  14984. */
  14985. getAnimationRange(name: string): Nullable<AnimationRange>;
  14986. /**
  14987. * Gets the list of all animation ranges defined on this skeleton
  14988. * @returns an array
  14989. */
  14990. getAnimationRanges(): Nullable<AnimationRange>[];
  14991. /**
  14992. * Copy animation range from a source skeleton.
  14993. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14994. * @param source defines the source skeleton
  14995. * @param name defines the name of the range to copy
  14996. * @param rescaleAsRequired defines if rescaling must be applied if required
  14997. * @returns true if operation was successful
  14998. */
  14999. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15000. /**
  15001. * Forces the skeleton to go to rest pose
  15002. */
  15003. returnToRest(): void;
  15004. private _getHighestAnimationFrame;
  15005. /**
  15006. * Begin a specific animation range
  15007. * @param name defines the name of the range to start
  15008. * @param loop defines if looping must be turned on (false by default)
  15009. * @param speedRatio defines the speed ratio to apply (1 by default)
  15010. * @param onAnimationEnd defines a callback which will be called when animation will end
  15011. * @returns a new animatable
  15012. */
  15013. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15014. /** @hidden */
  15015. _markAsDirty(): void;
  15016. /** @hidden */
  15017. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15018. /** @hidden */
  15019. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15020. private _computeTransformMatrices;
  15021. /**
  15022. * Build all resources required to render a skeleton
  15023. */
  15024. prepare(): void;
  15025. /**
  15026. * Gets the list of animatables currently running for this skeleton
  15027. * @returns an array of animatables
  15028. */
  15029. getAnimatables(): IAnimatable[];
  15030. /**
  15031. * Clone the current skeleton
  15032. * @param name defines the name of the new skeleton
  15033. * @param id defines the id of the new skeleton
  15034. * @returns the new skeleton
  15035. */
  15036. clone(name: string, id?: string): Skeleton;
  15037. /**
  15038. * Enable animation blending for this skeleton
  15039. * @param blendingSpeed defines the blending speed to apply
  15040. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15041. */
  15042. enableBlending(blendingSpeed?: number): void;
  15043. /**
  15044. * Releases all resources associated with the current skeleton
  15045. */
  15046. dispose(): void;
  15047. /**
  15048. * Serialize the skeleton in a JSON object
  15049. * @returns a JSON object
  15050. */
  15051. serialize(): any;
  15052. /**
  15053. * Creates a new skeleton from serialized data
  15054. * @param parsedSkeleton defines the serialized data
  15055. * @param scene defines the hosting scene
  15056. * @returns a new skeleton
  15057. */
  15058. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15059. /**
  15060. * Compute all node absolute transforms
  15061. * @param forceUpdate defines if computation must be done even if cache is up to date
  15062. */
  15063. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15064. /**
  15065. * Gets the root pose matrix
  15066. * @returns a matrix
  15067. */
  15068. getPoseMatrix(): Nullable<Matrix>;
  15069. /**
  15070. * Sorts bones per internal index
  15071. */
  15072. sortBones(): void;
  15073. private _sortBones;
  15074. }
  15075. }
  15076. declare module BABYLON {
  15077. /**
  15078. * Creates an instance based on a source mesh.
  15079. */
  15080. export class InstancedMesh extends AbstractMesh {
  15081. private _sourceMesh;
  15082. private _currentLOD;
  15083. /** @hidden */
  15084. _indexInSourceMeshInstanceArray: number;
  15085. constructor(name: string, source: Mesh);
  15086. /**
  15087. * Returns the string "InstancedMesh".
  15088. */
  15089. getClassName(): string;
  15090. /** Gets the list of lights affecting that mesh */
  15091. get lightSources(): Light[];
  15092. _resyncLightSources(): void;
  15093. _resyncLightSource(light: Light): void;
  15094. _removeLightSource(light: Light, dispose: boolean): void;
  15095. /**
  15096. * If the source mesh receives shadows
  15097. */
  15098. get receiveShadows(): boolean;
  15099. /**
  15100. * The material of the source mesh
  15101. */
  15102. get material(): Nullable<Material>;
  15103. /**
  15104. * Visibility of the source mesh
  15105. */
  15106. get visibility(): number;
  15107. /**
  15108. * Skeleton of the source mesh
  15109. */
  15110. get skeleton(): Nullable<Skeleton>;
  15111. /**
  15112. * Rendering ground id of the source mesh
  15113. */
  15114. get renderingGroupId(): number;
  15115. set renderingGroupId(value: number);
  15116. /**
  15117. * Returns the total number of vertices (integer).
  15118. */
  15119. getTotalVertices(): number;
  15120. /**
  15121. * Returns a positive integer : the total number of indices in this mesh geometry.
  15122. * @returns the numner of indices or zero if the mesh has no geometry.
  15123. */
  15124. getTotalIndices(): number;
  15125. /**
  15126. * The source mesh of the instance
  15127. */
  15128. get sourceMesh(): Mesh;
  15129. /**
  15130. * Is this node ready to be used/rendered
  15131. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15132. * @return {boolean} is it ready
  15133. */
  15134. isReady(completeCheck?: boolean): boolean;
  15135. /**
  15136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15137. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15138. * @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.
  15139. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15140. */
  15141. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15142. /**
  15143. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15144. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15145. * The `data` are either a numeric array either a Float32Array.
  15146. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15147. * 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).
  15148. * Note that a new underlying VertexBuffer object is created each call.
  15149. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15150. *
  15151. * Possible `kind` values :
  15152. * - VertexBuffer.PositionKind
  15153. * - VertexBuffer.UVKind
  15154. * - VertexBuffer.UV2Kind
  15155. * - VertexBuffer.UV3Kind
  15156. * - VertexBuffer.UV4Kind
  15157. * - VertexBuffer.UV5Kind
  15158. * - VertexBuffer.UV6Kind
  15159. * - VertexBuffer.ColorKind
  15160. * - VertexBuffer.MatricesIndicesKind
  15161. * - VertexBuffer.MatricesIndicesExtraKind
  15162. * - VertexBuffer.MatricesWeightsKind
  15163. * - VertexBuffer.MatricesWeightsExtraKind
  15164. *
  15165. * Returns the Mesh.
  15166. */
  15167. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15168. /**
  15169. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15170. * If the mesh has no geometry, it is simply returned as it is.
  15171. * The `data` are either a numeric array either a Float32Array.
  15172. * No new underlying VertexBuffer object is created.
  15173. * 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.
  15174. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15175. *
  15176. * Possible `kind` values :
  15177. * - VertexBuffer.PositionKind
  15178. * - VertexBuffer.UVKind
  15179. * - VertexBuffer.UV2Kind
  15180. * - VertexBuffer.UV3Kind
  15181. * - VertexBuffer.UV4Kind
  15182. * - VertexBuffer.UV5Kind
  15183. * - VertexBuffer.UV6Kind
  15184. * - VertexBuffer.ColorKind
  15185. * - VertexBuffer.MatricesIndicesKind
  15186. * - VertexBuffer.MatricesIndicesExtraKind
  15187. * - VertexBuffer.MatricesWeightsKind
  15188. * - VertexBuffer.MatricesWeightsExtraKind
  15189. *
  15190. * Returns the Mesh.
  15191. */
  15192. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15193. /**
  15194. * Sets the mesh indices.
  15195. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15196. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15197. * This method creates a new index buffer each call.
  15198. * Returns the Mesh.
  15199. */
  15200. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15201. /**
  15202. * Boolean : True if the mesh owns the requested kind of data.
  15203. */
  15204. isVerticesDataPresent(kind: string): boolean;
  15205. /**
  15206. * Returns an array of indices (IndicesArray).
  15207. */
  15208. getIndices(): Nullable<IndicesArray>;
  15209. get _positions(): Nullable<Vector3[]>;
  15210. /**
  15211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15212. * This means the mesh underlying bounding box and sphere are recomputed.
  15213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15214. * @returns the current mesh
  15215. */
  15216. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15217. /** @hidden */
  15218. _preActivate(): InstancedMesh;
  15219. /** @hidden */
  15220. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15221. /** @hidden */
  15222. _postActivate(): void;
  15223. getWorldMatrix(): Matrix;
  15224. get isAnInstance(): boolean;
  15225. /**
  15226. * Returns the current associated LOD AbstractMesh.
  15227. */
  15228. getLOD(camera: Camera): AbstractMesh;
  15229. /** @hidden */
  15230. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15231. /** @hidden */
  15232. _syncSubMeshes(): InstancedMesh;
  15233. /** @hidden */
  15234. _generatePointsArray(): boolean;
  15235. /**
  15236. * Creates a new InstancedMesh from the current mesh.
  15237. * - name (string) : the cloned mesh name
  15238. * - newParent (optional Node) : the optional Node to parent the clone to.
  15239. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15240. *
  15241. * Returns the clone.
  15242. */
  15243. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15244. /**
  15245. * Disposes the InstancedMesh.
  15246. * Returns nothing.
  15247. */
  15248. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15249. }
  15250. interface Mesh {
  15251. /**
  15252. * Register a custom buffer that will be instanced
  15253. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15254. * @param kind defines the buffer kind
  15255. * @param stride defines the stride in floats
  15256. */
  15257. registerInstancedBuffer(kind: string, stride: number): void;
  15258. /** @hidden */
  15259. _userInstancedBuffersStorage: {
  15260. data: {
  15261. [key: string]: Float32Array;
  15262. };
  15263. sizes: {
  15264. [key: string]: number;
  15265. };
  15266. vertexBuffers: {
  15267. [key: string]: Nullable<VertexBuffer>;
  15268. };
  15269. strides: {
  15270. [key: string]: number;
  15271. };
  15272. };
  15273. }
  15274. interface AbstractMesh {
  15275. /**
  15276. * Object used to store instanced buffers defined by user
  15277. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15278. */
  15279. instancedBuffers: {
  15280. [key: string]: any;
  15281. };
  15282. }
  15283. }
  15284. declare module BABYLON {
  15285. /**
  15286. * Defines the options associated with the creation of a shader material.
  15287. */
  15288. export interface IShaderMaterialOptions {
  15289. /**
  15290. * Does the material work in alpha blend mode
  15291. */
  15292. needAlphaBlending: boolean;
  15293. /**
  15294. * Does the material work in alpha test mode
  15295. */
  15296. needAlphaTesting: boolean;
  15297. /**
  15298. * The list of attribute names used in the shader
  15299. */
  15300. attributes: string[];
  15301. /**
  15302. * The list of unifrom names used in the shader
  15303. */
  15304. uniforms: string[];
  15305. /**
  15306. * The list of UBO names used in the shader
  15307. */
  15308. uniformBuffers: string[];
  15309. /**
  15310. * The list of sampler names used in the shader
  15311. */
  15312. samplers: string[];
  15313. /**
  15314. * The list of defines used in the shader
  15315. */
  15316. defines: string[];
  15317. }
  15318. /**
  15319. * 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.
  15320. *
  15321. * This returned material effects how the mesh will look based on the code in the shaders.
  15322. *
  15323. * @see http://doc.babylonjs.com/how_to/shader_material
  15324. */
  15325. export class ShaderMaterial extends Material {
  15326. private _shaderPath;
  15327. private _options;
  15328. private _textures;
  15329. private _textureArrays;
  15330. private _floats;
  15331. private _ints;
  15332. private _floatsArrays;
  15333. private _colors3;
  15334. private _colors3Arrays;
  15335. private _colors4;
  15336. private _colors4Arrays;
  15337. private _vectors2;
  15338. private _vectors3;
  15339. private _vectors4;
  15340. private _matrices;
  15341. private _matrixArrays;
  15342. private _matrices3x3;
  15343. private _matrices2x2;
  15344. private _vectors2Arrays;
  15345. private _vectors3Arrays;
  15346. private _vectors4Arrays;
  15347. private _cachedWorldViewMatrix;
  15348. private _cachedWorldViewProjectionMatrix;
  15349. private _renderId;
  15350. private _multiview;
  15351. /**
  15352. * Instantiate a new shader material.
  15353. * 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.
  15354. * This returned material effects how the mesh will look based on the code in the shaders.
  15355. * @see http://doc.babylonjs.com/how_to/shader_material
  15356. * @param name Define the name of the material in the scene
  15357. * @param scene Define the scene the material belongs to
  15358. * @param shaderPath Defines the route to the shader code in one of three ways:
  15359. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15360. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15361. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15362. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15363. * @param options Define the options used to create the shader
  15364. */
  15365. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15366. /**
  15367. * Gets the shader path used to define the shader code
  15368. * It can be modified to trigger a new compilation
  15369. */
  15370. get shaderPath(): any;
  15371. /**
  15372. * Sets the shader path used to define the shader code
  15373. * It can be modified to trigger a new compilation
  15374. */
  15375. set shaderPath(shaderPath: any);
  15376. /**
  15377. * Gets the options used to compile the shader.
  15378. * They can be modified to trigger a new compilation
  15379. */
  15380. get options(): IShaderMaterialOptions;
  15381. /**
  15382. * Gets the current class name of the material e.g. "ShaderMaterial"
  15383. * Mainly use in serialization.
  15384. * @returns the class name
  15385. */
  15386. getClassName(): string;
  15387. /**
  15388. * Specifies if the material will require alpha blending
  15389. * @returns a boolean specifying if alpha blending is needed
  15390. */
  15391. needAlphaBlending(): boolean;
  15392. /**
  15393. * Specifies if this material should be rendered in alpha test mode
  15394. * @returns a boolean specifying if an alpha test is needed.
  15395. */
  15396. needAlphaTesting(): boolean;
  15397. private _checkUniform;
  15398. /**
  15399. * Set a texture in the shader.
  15400. * @param name Define the name of the uniform samplers as defined in the shader
  15401. * @param texture Define the texture to bind to this sampler
  15402. * @return the material itself allowing "fluent" like uniform updates
  15403. */
  15404. setTexture(name: string, texture: Texture): ShaderMaterial;
  15405. /**
  15406. * Set a texture array in the shader.
  15407. * @param name Define the name of the uniform sampler array as defined in the shader
  15408. * @param textures Define the list of textures to bind to this sampler
  15409. * @return the material itself allowing "fluent" like uniform updates
  15410. */
  15411. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15412. /**
  15413. * Set a float in the shader.
  15414. * @param name Define the name of the uniform as defined in the shader
  15415. * @param value Define the value to give to the uniform
  15416. * @return the material itself allowing "fluent" like uniform updates
  15417. */
  15418. setFloat(name: string, value: number): ShaderMaterial;
  15419. /**
  15420. * Set a int in the shader.
  15421. * @param name Define the name of the uniform as defined in the shader
  15422. * @param value Define the value to give to the uniform
  15423. * @return the material itself allowing "fluent" like uniform updates
  15424. */
  15425. setInt(name: string, value: number): ShaderMaterial;
  15426. /**
  15427. * Set an array of floats in the shader.
  15428. * @param name Define the name of the uniform as defined in the shader
  15429. * @param value Define the value to give to the uniform
  15430. * @return the material itself allowing "fluent" like uniform updates
  15431. */
  15432. setFloats(name: string, value: number[]): ShaderMaterial;
  15433. /**
  15434. * Set a vec3 in the shader from a Color3.
  15435. * @param name Define the name of the uniform as defined in the shader
  15436. * @param value Define the value to give to the uniform
  15437. * @return the material itself allowing "fluent" like uniform updates
  15438. */
  15439. setColor3(name: string, value: Color3): ShaderMaterial;
  15440. /**
  15441. * Set a vec3 array in the shader from a Color3 array.
  15442. * @param name Define the name of the uniform as defined in the shader
  15443. * @param value Define the value to give to the uniform
  15444. * @return the material itself allowing "fluent" like uniform updates
  15445. */
  15446. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15447. /**
  15448. * Set a vec4 in the shader from a Color4.
  15449. * @param name Define the name of the uniform as defined in the shader
  15450. * @param value Define the value to give to the uniform
  15451. * @return the material itself allowing "fluent" like uniform updates
  15452. */
  15453. setColor4(name: string, value: Color4): ShaderMaterial;
  15454. /**
  15455. * Set a vec4 array in the shader from a Color4 array.
  15456. * @param name Define the name of the uniform as defined in the shader
  15457. * @param value Define the value to give to the uniform
  15458. * @return the material itself allowing "fluent" like uniform updates
  15459. */
  15460. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15461. /**
  15462. * Set a vec2 in the shader from a Vector2.
  15463. * @param name Define the name of the uniform as defined in the shader
  15464. * @param value Define the value to give to the uniform
  15465. * @return the material itself allowing "fluent" like uniform updates
  15466. */
  15467. setVector2(name: string, value: Vector2): ShaderMaterial;
  15468. /**
  15469. * Set a vec3 in the shader from a Vector3.
  15470. * @param name Define the name of the uniform as defined in the shader
  15471. * @param value Define the value to give to the uniform
  15472. * @return the material itself allowing "fluent" like uniform updates
  15473. */
  15474. setVector3(name: string, value: Vector3): ShaderMaterial;
  15475. /**
  15476. * Set a vec4 in the shader from a Vector4.
  15477. * @param name Define the name of the uniform as defined in the shader
  15478. * @param value Define the value to give to the uniform
  15479. * @return the material itself allowing "fluent" like uniform updates
  15480. */
  15481. setVector4(name: string, value: Vector4): ShaderMaterial;
  15482. /**
  15483. * Set a mat4 in the shader from a Matrix.
  15484. * @param name Define the name of the uniform as defined in the shader
  15485. * @param value Define the value to give to the uniform
  15486. * @return the material itself allowing "fluent" like uniform updates
  15487. */
  15488. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15489. /**
  15490. * Set a float32Array in the shader from a matrix array.
  15491. * @param name Define the name of the uniform as defined in the shader
  15492. * @param value Define the value to give to the uniform
  15493. * @return the material itself allowing "fluent" like uniform updates
  15494. */
  15495. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15496. /**
  15497. * Set a mat3 in the shader from a Float32Array.
  15498. * @param name Define the name of the uniform as defined in the shader
  15499. * @param value Define the value to give to the uniform
  15500. * @return the material itself allowing "fluent" like uniform updates
  15501. */
  15502. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15503. /**
  15504. * Set a mat2 in the shader from a Float32Array.
  15505. * @param name Define the name of the uniform as defined in the shader
  15506. * @param value Define the value to give to the uniform
  15507. * @return the material itself allowing "fluent" like uniform updates
  15508. */
  15509. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15510. /**
  15511. * Set a vec2 array in the shader from a number array.
  15512. * @param name Define the name of the uniform as defined in the shader
  15513. * @param value Define the value to give to the uniform
  15514. * @return the material itself allowing "fluent" like uniform updates
  15515. */
  15516. setArray2(name: string, value: number[]): ShaderMaterial;
  15517. /**
  15518. * Set a vec3 array in the shader from a number array.
  15519. * @param name Define the name of the uniform as defined in the shader
  15520. * @param value Define the value to give to the uniform
  15521. * @return the material itself allowing "fluent" like uniform updates
  15522. */
  15523. setArray3(name: string, value: number[]): ShaderMaterial;
  15524. /**
  15525. * Set a vec4 array in the shader from a number array.
  15526. * @param name Define the name of the uniform as defined in the shader
  15527. * @param value Define the value to give to the uniform
  15528. * @return the material itself allowing "fluent" like uniform updates
  15529. */
  15530. setArray4(name: string, value: number[]): ShaderMaterial;
  15531. private _checkCache;
  15532. /**
  15533. * Specifies that the submesh is ready to be used
  15534. * @param mesh defines the mesh to check
  15535. * @param subMesh defines which submesh to check
  15536. * @param useInstances specifies that instances should be used
  15537. * @returns a boolean indicating that the submesh is ready or not
  15538. */
  15539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15540. /**
  15541. * Checks if the material is ready to render the requested mesh
  15542. * @param mesh Define the mesh to render
  15543. * @param useInstances Define whether or not the material is used with instances
  15544. * @returns true if ready, otherwise false
  15545. */
  15546. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15547. /**
  15548. * Binds the world matrix to the material
  15549. * @param world defines the world transformation matrix
  15550. */
  15551. bindOnlyWorldMatrix(world: Matrix): void;
  15552. /**
  15553. * Binds the material to the mesh
  15554. * @param world defines the world transformation matrix
  15555. * @param mesh defines the mesh to bind the material to
  15556. */
  15557. bind(world: Matrix, mesh?: Mesh): void;
  15558. /**
  15559. * Gets the active textures from the material
  15560. * @returns an array of textures
  15561. */
  15562. getActiveTextures(): BaseTexture[];
  15563. /**
  15564. * Specifies if the material uses a texture
  15565. * @param texture defines the texture to check against the material
  15566. * @returns a boolean specifying if the material uses the texture
  15567. */
  15568. hasTexture(texture: BaseTexture): boolean;
  15569. /**
  15570. * Makes a duplicate of the material, and gives it a new name
  15571. * @param name defines the new name for the duplicated material
  15572. * @returns the cloned material
  15573. */
  15574. clone(name: string): ShaderMaterial;
  15575. /**
  15576. * Disposes the material
  15577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15579. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15580. */
  15581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15582. /**
  15583. * Serializes this material in a JSON representation
  15584. * @returns the serialized material object
  15585. */
  15586. serialize(): any;
  15587. /**
  15588. * Creates a shader material from parsed shader material data
  15589. * @param source defines the JSON represnetation of the material
  15590. * @param scene defines the hosting scene
  15591. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15592. * @returns a new material
  15593. */
  15594. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15595. }
  15596. }
  15597. declare module BABYLON {
  15598. /** @hidden */
  15599. export var colorPixelShader: {
  15600. name: string;
  15601. shader: string;
  15602. };
  15603. }
  15604. declare module BABYLON {
  15605. /** @hidden */
  15606. export var colorVertexShader: {
  15607. name: string;
  15608. shader: string;
  15609. };
  15610. }
  15611. declare module BABYLON {
  15612. /**
  15613. * Line mesh
  15614. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15615. */
  15616. export class LinesMesh extends Mesh {
  15617. /**
  15618. * If vertex color should be applied to the mesh
  15619. */
  15620. readonly useVertexColor?: boolean | undefined;
  15621. /**
  15622. * If vertex alpha should be applied to the mesh
  15623. */
  15624. readonly useVertexAlpha?: boolean | undefined;
  15625. /**
  15626. * Color of the line (Default: White)
  15627. */
  15628. color: Color3;
  15629. /**
  15630. * Alpha of the line (Default: 1)
  15631. */
  15632. alpha: number;
  15633. /**
  15634. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15635. * This margin is expressed in world space coordinates, so its value may vary.
  15636. * Default value is 0.1
  15637. */
  15638. intersectionThreshold: number;
  15639. private _colorShader;
  15640. private color4;
  15641. /**
  15642. * Creates a new LinesMesh
  15643. * @param name defines the name
  15644. * @param scene defines the hosting scene
  15645. * @param parent defines the parent mesh if any
  15646. * @param source defines the optional source LinesMesh used to clone data from
  15647. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15648. * When false, achieved by calling a clone(), also passing False.
  15649. * This will make creation of children, recursive.
  15650. * @param useVertexColor defines if this LinesMesh supports vertex color
  15651. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15652. */
  15653. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15654. /**
  15655. * If vertex color should be applied to the mesh
  15656. */
  15657. useVertexColor?: boolean | undefined,
  15658. /**
  15659. * If vertex alpha should be applied to the mesh
  15660. */
  15661. useVertexAlpha?: boolean | undefined);
  15662. private _addClipPlaneDefine;
  15663. private _removeClipPlaneDefine;
  15664. isReady(): boolean;
  15665. /**
  15666. * Returns the string "LineMesh"
  15667. */
  15668. getClassName(): string;
  15669. /**
  15670. * @hidden
  15671. */
  15672. get material(): Material;
  15673. /**
  15674. * @hidden
  15675. */
  15676. set material(value: Material);
  15677. /**
  15678. * @hidden
  15679. */
  15680. get checkCollisions(): boolean;
  15681. /** @hidden */
  15682. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15683. /** @hidden */
  15684. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15685. /**
  15686. * Disposes of the line mesh
  15687. * @param doNotRecurse If children should be disposed
  15688. */
  15689. dispose(doNotRecurse?: boolean): void;
  15690. /**
  15691. * Returns a new LineMesh object cloned from the current one.
  15692. */
  15693. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15694. /**
  15695. * Creates a new InstancedLinesMesh object from the mesh model.
  15696. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15697. * @param name defines the name of the new instance
  15698. * @returns a new InstancedLinesMesh
  15699. */
  15700. createInstance(name: string): InstancedLinesMesh;
  15701. }
  15702. /**
  15703. * Creates an instance based on a source LinesMesh
  15704. */
  15705. export class InstancedLinesMesh extends InstancedMesh {
  15706. /**
  15707. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15708. * This margin is expressed in world space coordinates, so its value may vary.
  15709. * Initilized with the intersectionThreshold value of the source LinesMesh
  15710. */
  15711. intersectionThreshold: number;
  15712. constructor(name: string, source: LinesMesh);
  15713. /**
  15714. * Returns the string "InstancedLinesMesh".
  15715. */
  15716. getClassName(): string;
  15717. }
  15718. }
  15719. declare module BABYLON {
  15720. /** @hidden */
  15721. export var linePixelShader: {
  15722. name: string;
  15723. shader: string;
  15724. };
  15725. }
  15726. declare module BABYLON {
  15727. /** @hidden */
  15728. export var lineVertexShader: {
  15729. name: string;
  15730. shader: string;
  15731. };
  15732. }
  15733. declare module BABYLON {
  15734. interface AbstractMesh {
  15735. /**
  15736. * Gets the edgesRenderer associated with the mesh
  15737. */
  15738. edgesRenderer: Nullable<EdgesRenderer>;
  15739. }
  15740. interface LinesMesh {
  15741. /**
  15742. * Enables the edge rendering mode on the mesh.
  15743. * This mode makes the mesh edges visible
  15744. * @param epsilon defines the maximal distance between two angles to detect a face
  15745. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15746. * @returns the currentAbstractMesh
  15747. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15748. */
  15749. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15750. }
  15751. interface InstancedLinesMesh {
  15752. /**
  15753. * Enables the edge rendering mode on the mesh.
  15754. * This mode makes the mesh edges visible
  15755. * @param epsilon defines the maximal distance between two angles to detect a face
  15756. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15757. * @returns the current InstancedLinesMesh
  15758. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15759. */
  15760. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15761. }
  15762. /**
  15763. * Defines the minimum contract an Edges renderer should follow.
  15764. */
  15765. export interface IEdgesRenderer extends IDisposable {
  15766. /**
  15767. * Gets or sets a boolean indicating if the edgesRenderer is active
  15768. */
  15769. isEnabled: boolean;
  15770. /**
  15771. * Renders the edges of the attached mesh,
  15772. */
  15773. render(): void;
  15774. /**
  15775. * Checks wether or not the edges renderer is ready to render.
  15776. * @return true if ready, otherwise false.
  15777. */
  15778. isReady(): boolean;
  15779. }
  15780. /**
  15781. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15782. */
  15783. export class EdgesRenderer implements IEdgesRenderer {
  15784. /**
  15785. * Define the size of the edges with an orthographic camera
  15786. */
  15787. edgesWidthScalerForOrthographic: number;
  15788. /**
  15789. * Define the size of the edges with a perspective camera
  15790. */
  15791. edgesWidthScalerForPerspective: number;
  15792. protected _source: AbstractMesh;
  15793. protected _linesPositions: number[];
  15794. protected _linesNormals: number[];
  15795. protected _linesIndices: number[];
  15796. protected _epsilon: number;
  15797. protected _indicesCount: number;
  15798. protected _lineShader: ShaderMaterial;
  15799. protected _ib: DataBuffer;
  15800. protected _buffers: {
  15801. [key: string]: Nullable<VertexBuffer>;
  15802. };
  15803. protected _checkVerticesInsteadOfIndices: boolean;
  15804. private _meshRebuildObserver;
  15805. private _meshDisposeObserver;
  15806. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15807. isEnabled: boolean;
  15808. /**
  15809. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15810. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15811. * @param source Mesh used to create edges
  15812. * @param epsilon sum of angles in adjacency to check for edge
  15813. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15814. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15815. */
  15816. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15817. protected _prepareRessources(): void;
  15818. /** @hidden */
  15819. _rebuild(): void;
  15820. /**
  15821. * Releases the required resources for the edges renderer
  15822. */
  15823. dispose(): void;
  15824. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15825. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15826. /**
  15827. * Checks if the pair of p0 and p1 is en edge
  15828. * @param faceIndex
  15829. * @param edge
  15830. * @param faceNormals
  15831. * @param p0
  15832. * @param p1
  15833. * @private
  15834. */
  15835. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15836. /**
  15837. * push line into the position, normal and index buffer
  15838. * @protected
  15839. */
  15840. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15841. /**
  15842. * Generates lines edges from adjacencjes
  15843. * @private
  15844. */
  15845. _generateEdgesLines(): void;
  15846. /**
  15847. * Checks wether or not the edges renderer is ready to render.
  15848. * @return true if ready, otherwise false.
  15849. */
  15850. isReady(): boolean;
  15851. /**
  15852. * Renders the edges of the attached mesh,
  15853. */
  15854. render(): void;
  15855. }
  15856. /**
  15857. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15858. */
  15859. export class LineEdgesRenderer extends EdgesRenderer {
  15860. /**
  15861. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15862. * @param source LineMesh used to generate edges
  15863. * @param epsilon not important (specified angle for edge detection)
  15864. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15865. */
  15866. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15867. /**
  15868. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15869. */
  15870. _generateEdgesLines(): void;
  15871. }
  15872. }
  15873. declare module BABYLON {
  15874. /**
  15875. * This represents the object necessary to create a rendering group.
  15876. * This is exclusively used and created by the rendering manager.
  15877. * To modify the behavior, you use the available helpers in your scene or meshes.
  15878. * @hidden
  15879. */
  15880. export class RenderingGroup {
  15881. index: number;
  15882. private static _zeroVector;
  15883. private _scene;
  15884. private _opaqueSubMeshes;
  15885. private _transparentSubMeshes;
  15886. private _alphaTestSubMeshes;
  15887. private _depthOnlySubMeshes;
  15888. private _particleSystems;
  15889. private _spriteManagers;
  15890. private _opaqueSortCompareFn;
  15891. private _alphaTestSortCompareFn;
  15892. private _transparentSortCompareFn;
  15893. private _renderOpaque;
  15894. private _renderAlphaTest;
  15895. private _renderTransparent;
  15896. /** @hidden */
  15897. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15898. onBeforeTransparentRendering: () => void;
  15899. /**
  15900. * Set the opaque sort comparison function.
  15901. * If null the sub meshes will be render in the order they were created
  15902. */
  15903. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15904. /**
  15905. * Set the alpha test sort comparison function.
  15906. * If null the sub meshes will be render in the order they were created
  15907. */
  15908. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15909. /**
  15910. * Set the transparent sort comparison function.
  15911. * If null the sub meshes will be render in the order they were created
  15912. */
  15913. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15914. /**
  15915. * Creates a new rendering group.
  15916. * @param index The rendering group index
  15917. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15918. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15919. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15920. */
  15921. 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>);
  15922. /**
  15923. * Render all the sub meshes contained in the group.
  15924. * @param customRenderFunction Used to override the default render behaviour of the group.
  15925. * @returns true if rendered some submeshes.
  15926. */
  15927. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15928. /**
  15929. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15930. * @param subMeshes The submeshes to render
  15931. */
  15932. private renderOpaqueSorted;
  15933. /**
  15934. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15935. * @param subMeshes The submeshes to render
  15936. */
  15937. private renderAlphaTestSorted;
  15938. /**
  15939. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15940. * @param subMeshes The submeshes to render
  15941. */
  15942. private renderTransparentSorted;
  15943. /**
  15944. * Renders the submeshes in a specified order.
  15945. * @param subMeshes The submeshes to sort before render
  15946. * @param sortCompareFn The comparison function use to sort
  15947. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15948. * @param transparent Specifies to activate blending if true
  15949. */
  15950. private static renderSorted;
  15951. /**
  15952. * Renders the submeshes in the order they were dispatched (no sort applied).
  15953. * @param subMeshes The submeshes to render
  15954. */
  15955. private static renderUnsorted;
  15956. /**
  15957. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15958. * are rendered back to front if in the same alpha index.
  15959. *
  15960. * @param a The first submesh
  15961. * @param b The second submesh
  15962. * @returns The result of the comparison
  15963. */
  15964. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15965. /**
  15966. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15967. * are rendered back to front.
  15968. *
  15969. * @param a The first submesh
  15970. * @param b The second submesh
  15971. * @returns The result of the comparison
  15972. */
  15973. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15974. /**
  15975. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15976. * are rendered front to back (prevent overdraw).
  15977. *
  15978. * @param a The first submesh
  15979. * @param b The second submesh
  15980. * @returns The result of the comparison
  15981. */
  15982. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15983. /**
  15984. * Resets the different lists of submeshes to prepare a new frame.
  15985. */
  15986. prepare(): void;
  15987. dispose(): void;
  15988. /**
  15989. * Inserts the submesh in its correct queue depending on its material.
  15990. * @param subMesh The submesh to dispatch
  15991. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15992. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15993. */
  15994. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15995. dispatchSprites(spriteManager: ISpriteManager): void;
  15996. dispatchParticles(particleSystem: IParticleSystem): void;
  15997. private _renderParticles;
  15998. private _renderSprites;
  15999. }
  16000. }
  16001. declare module BABYLON {
  16002. /**
  16003. * Interface describing the different options available in the rendering manager
  16004. * regarding Auto Clear between groups.
  16005. */
  16006. export interface IRenderingManagerAutoClearSetup {
  16007. /**
  16008. * Defines whether or not autoclear is enable.
  16009. */
  16010. autoClear: boolean;
  16011. /**
  16012. * Defines whether or not to autoclear the depth buffer.
  16013. */
  16014. depth: boolean;
  16015. /**
  16016. * Defines whether or not to autoclear the stencil buffer.
  16017. */
  16018. stencil: boolean;
  16019. }
  16020. /**
  16021. * This class is used by the onRenderingGroupObservable
  16022. */
  16023. export class RenderingGroupInfo {
  16024. /**
  16025. * The Scene that being rendered
  16026. */
  16027. scene: Scene;
  16028. /**
  16029. * The camera currently used for the rendering pass
  16030. */
  16031. camera: Nullable<Camera>;
  16032. /**
  16033. * The ID of the renderingGroup being processed
  16034. */
  16035. renderingGroupId: number;
  16036. }
  16037. /**
  16038. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16039. * It is enable to manage the different groups as well as the different necessary sort functions.
  16040. * This should not be used directly aside of the few static configurations
  16041. */
  16042. export class RenderingManager {
  16043. /**
  16044. * The max id used for rendering groups (not included)
  16045. */
  16046. static MAX_RENDERINGGROUPS: number;
  16047. /**
  16048. * The min id used for rendering groups (included)
  16049. */
  16050. static MIN_RENDERINGGROUPS: number;
  16051. /**
  16052. * Used to globally prevent autoclearing scenes.
  16053. */
  16054. static AUTOCLEAR: boolean;
  16055. /**
  16056. * @hidden
  16057. */
  16058. _useSceneAutoClearSetup: boolean;
  16059. private _scene;
  16060. private _renderingGroups;
  16061. private _depthStencilBufferAlreadyCleaned;
  16062. private _autoClearDepthStencil;
  16063. private _customOpaqueSortCompareFn;
  16064. private _customAlphaTestSortCompareFn;
  16065. private _customTransparentSortCompareFn;
  16066. private _renderingGroupInfo;
  16067. /**
  16068. * Instantiates a new rendering group for a particular scene
  16069. * @param scene Defines the scene the groups belongs to
  16070. */
  16071. constructor(scene: Scene);
  16072. private _clearDepthStencilBuffer;
  16073. /**
  16074. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16075. * @hidden
  16076. */
  16077. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16078. /**
  16079. * Resets the different information of the group to prepare a new frame
  16080. * @hidden
  16081. */
  16082. reset(): void;
  16083. /**
  16084. * Dispose and release the group and its associated resources.
  16085. * @hidden
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Clear the info related to rendering groups preventing retention points during dispose.
  16090. */
  16091. freeRenderingGroups(): void;
  16092. private _prepareRenderingGroup;
  16093. /**
  16094. * Add a sprite manager to the rendering manager in order to render it this frame.
  16095. * @param spriteManager Define the sprite manager to render
  16096. */
  16097. dispatchSprites(spriteManager: ISpriteManager): void;
  16098. /**
  16099. * Add a particle system to the rendering manager in order to render it this frame.
  16100. * @param particleSystem Define the particle system to render
  16101. */
  16102. dispatchParticles(particleSystem: IParticleSystem): void;
  16103. /**
  16104. * Add a submesh to the manager in order to render it this frame
  16105. * @param subMesh The submesh to dispatch
  16106. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16107. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16108. */
  16109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16110. /**
  16111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16112. * This allowed control for front to back rendering or reversly depending of the special needs.
  16113. *
  16114. * @param renderingGroupId The rendering group id corresponding to its index
  16115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16118. */
  16119. 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;
  16120. /**
  16121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16122. *
  16123. * @param renderingGroupId The rendering group id corresponding to its index
  16124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16125. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16126. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16127. */
  16128. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16129. /**
  16130. * Gets the current auto clear configuration for one rendering group of the rendering
  16131. * manager.
  16132. * @param index the rendering group index to get the information for
  16133. * @returns The auto clear setup for the requested rendering group
  16134. */
  16135. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16136. }
  16137. }
  16138. declare module BABYLON {
  16139. /**
  16140. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16141. */
  16142. export interface ICustomShaderOptions {
  16143. /**
  16144. * Gets or sets the custom shader name to use
  16145. */
  16146. shaderName: string;
  16147. /**
  16148. * The list of attribute names used in the shader
  16149. */
  16150. attributes?: string[];
  16151. /**
  16152. * The list of unifrom names used in the shader
  16153. */
  16154. uniforms?: string[];
  16155. /**
  16156. * The list of sampler names used in the shader
  16157. */
  16158. samplers?: string[];
  16159. /**
  16160. * The list of defines used in the shader
  16161. */
  16162. defines?: string[];
  16163. }
  16164. /**
  16165. * Interface to implement to create a shadow generator compatible with BJS.
  16166. */
  16167. export interface IShadowGenerator {
  16168. /**
  16169. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16170. * @returns The render target texture if present otherwise, null
  16171. */
  16172. getShadowMap(): Nullable<RenderTargetTexture>;
  16173. /**
  16174. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16175. * @param subMesh The submesh we want to render in the shadow map
  16176. * @param useInstances Defines wether will draw in the map using instances
  16177. * @returns true if ready otherwise, false
  16178. */
  16179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16180. /**
  16181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16182. * @param defines Defines of the material we want to update
  16183. * @param lightIndex Index of the light in the enabled light list of the material
  16184. */
  16185. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16186. /**
  16187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16188. * defined in the generator but impacting the effect).
  16189. * It implies the unifroms available on the materials are the standard BJS ones.
  16190. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16191. * @param effect The effect we are binfing the information for
  16192. */
  16193. bindShadowLight(lightIndex: string, effect: Effect): void;
  16194. /**
  16195. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16196. * (eq to shadow prjection matrix * light transform matrix)
  16197. * @returns The transform matrix used to create the shadow map
  16198. */
  16199. getTransformMatrix(): Matrix;
  16200. /**
  16201. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16202. * Cube and 2D textures for instance.
  16203. */
  16204. recreateShadowMap(): void;
  16205. /**
  16206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16207. * @param onCompiled Callback triggered at the and of the effects compilation
  16208. * @param options Sets of optional options forcing the compilation with different modes
  16209. */
  16210. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16211. useInstances: boolean;
  16212. }>): void;
  16213. /**
  16214. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16215. * @param options Sets of optional options forcing the compilation with different modes
  16216. * @returns A promise that resolves when the compilation completes
  16217. */
  16218. forceCompilationAsync(options?: Partial<{
  16219. useInstances: boolean;
  16220. }>): Promise<void>;
  16221. /**
  16222. * Serializes the shadow generator setup to a json object.
  16223. * @returns The serialized JSON object
  16224. */
  16225. serialize(): any;
  16226. /**
  16227. * Disposes the Shadow map and related Textures and effects.
  16228. */
  16229. dispose(): void;
  16230. }
  16231. /**
  16232. * Default implementation IShadowGenerator.
  16233. * This is the main object responsible of generating shadows in the framework.
  16234. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16235. */
  16236. export class ShadowGenerator implements IShadowGenerator {
  16237. /**
  16238. * Name of the shadow generator class
  16239. */
  16240. static CLASSNAME: string;
  16241. /**
  16242. * Shadow generator mode None: no filtering applied.
  16243. */
  16244. static readonly FILTER_NONE: number;
  16245. /**
  16246. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16247. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16248. */
  16249. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16250. /**
  16251. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16252. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16253. */
  16254. static readonly FILTER_POISSONSAMPLING: number;
  16255. /**
  16256. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16257. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16258. */
  16259. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16260. /**
  16261. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16262. * edge artifacts on steep falloff.
  16263. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16264. */
  16265. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16266. /**
  16267. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16268. * edge artifacts on steep falloff.
  16269. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16270. */
  16271. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16272. /**
  16273. * Shadow generator mode PCF: Percentage Closer Filtering
  16274. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16275. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16276. */
  16277. static readonly FILTER_PCF: number;
  16278. /**
  16279. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16280. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16281. * Contact Hardening
  16282. */
  16283. static readonly FILTER_PCSS: number;
  16284. /**
  16285. * Reserved for PCF and PCSS
  16286. * Highest Quality.
  16287. *
  16288. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16289. *
  16290. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16291. */
  16292. static readonly QUALITY_HIGH: number;
  16293. /**
  16294. * Reserved for PCF and PCSS
  16295. * Good tradeoff for quality/perf cross devices
  16296. *
  16297. * Execute PCF on a 3*3 kernel.
  16298. *
  16299. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16300. */
  16301. static readonly QUALITY_MEDIUM: number;
  16302. /**
  16303. * Reserved for PCF and PCSS
  16304. * The lowest quality but the fastest.
  16305. *
  16306. * Execute PCF on a 1*1 kernel.
  16307. *
  16308. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16309. */
  16310. static readonly QUALITY_LOW: number;
  16311. /** Gets or sets the custom shader name to use */
  16312. customShaderOptions: ICustomShaderOptions;
  16313. /**
  16314. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16315. */
  16316. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16317. /**
  16318. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16319. */
  16320. onAfterShadowMapRenderObservable: Observable<Effect>;
  16321. /**
  16322. * Observable triggered before a mesh is rendered in the shadow map.
  16323. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16324. */
  16325. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16326. /**
  16327. * Observable triggered after a mesh is rendered in the shadow map.
  16328. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16329. */
  16330. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16331. protected _bias: number;
  16332. /**
  16333. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16334. */
  16335. get bias(): number;
  16336. /**
  16337. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16338. */
  16339. set bias(bias: number);
  16340. protected _normalBias: number;
  16341. /**
  16342. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16343. */
  16344. get normalBias(): number;
  16345. /**
  16346. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16347. */
  16348. set normalBias(normalBias: number);
  16349. protected _blurBoxOffset: number;
  16350. /**
  16351. * Gets the blur box offset: offset applied during the blur pass.
  16352. * Only useful if useKernelBlur = false
  16353. */
  16354. get blurBoxOffset(): number;
  16355. /**
  16356. * Sets the blur box offset: offset applied during the blur pass.
  16357. * Only useful if useKernelBlur = false
  16358. */
  16359. set blurBoxOffset(value: number);
  16360. protected _blurScale: number;
  16361. /**
  16362. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16363. * 2 means half of the size.
  16364. */
  16365. get blurScale(): number;
  16366. /**
  16367. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16368. * 2 means half of the size.
  16369. */
  16370. set blurScale(value: number);
  16371. protected _blurKernel: number;
  16372. /**
  16373. * Gets the blur kernel: kernel size of the blur pass.
  16374. * Only useful if useKernelBlur = true
  16375. */
  16376. get blurKernel(): number;
  16377. /**
  16378. * Sets the blur kernel: kernel size of the blur pass.
  16379. * Only useful if useKernelBlur = true
  16380. */
  16381. set blurKernel(value: number);
  16382. protected _useKernelBlur: boolean;
  16383. /**
  16384. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16385. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16386. */
  16387. get useKernelBlur(): boolean;
  16388. /**
  16389. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16390. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16391. */
  16392. set useKernelBlur(value: boolean);
  16393. protected _depthScale: number;
  16394. /**
  16395. * Gets the depth scale used in ESM mode.
  16396. */
  16397. get depthScale(): number;
  16398. /**
  16399. * Sets the depth scale used in ESM mode.
  16400. * This can override the scale stored on the light.
  16401. */
  16402. set depthScale(value: number);
  16403. protected _validateFilter(filter: number): number;
  16404. protected _filter: number;
  16405. /**
  16406. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16407. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16408. */
  16409. get filter(): number;
  16410. /**
  16411. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16412. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16413. */
  16414. set filter(value: number);
  16415. /**
  16416. * Gets if the current filter is set to Poisson Sampling.
  16417. */
  16418. get usePoissonSampling(): boolean;
  16419. /**
  16420. * Sets the current filter to Poisson Sampling.
  16421. */
  16422. set usePoissonSampling(value: boolean);
  16423. /**
  16424. * Gets if the current filter is set to ESM.
  16425. */
  16426. get useExponentialShadowMap(): boolean;
  16427. /**
  16428. * Sets the current filter is to ESM.
  16429. */
  16430. set useExponentialShadowMap(value: boolean);
  16431. /**
  16432. * Gets if the current filter is set to filtered ESM.
  16433. */
  16434. get useBlurExponentialShadowMap(): boolean;
  16435. /**
  16436. * Gets if the current filter is set to filtered ESM.
  16437. */
  16438. set useBlurExponentialShadowMap(value: boolean);
  16439. /**
  16440. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16441. * exponential to prevent steep falloff artifacts).
  16442. */
  16443. get useCloseExponentialShadowMap(): boolean;
  16444. /**
  16445. * Sets the current filter to "close ESM" (using the inverse of the
  16446. * exponential to prevent steep falloff artifacts).
  16447. */
  16448. set useCloseExponentialShadowMap(value: boolean);
  16449. /**
  16450. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16451. * exponential to prevent steep falloff artifacts).
  16452. */
  16453. get useBlurCloseExponentialShadowMap(): boolean;
  16454. /**
  16455. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16456. * exponential to prevent steep falloff artifacts).
  16457. */
  16458. set useBlurCloseExponentialShadowMap(value: boolean);
  16459. /**
  16460. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16461. */
  16462. get usePercentageCloserFiltering(): boolean;
  16463. /**
  16464. * Sets the current filter to "PCF" (percentage closer filtering).
  16465. */
  16466. set usePercentageCloserFiltering(value: boolean);
  16467. protected _filteringQuality: number;
  16468. /**
  16469. * Gets the PCF or PCSS Quality.
  16470. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16471. */
  16472. get filteringQuality(): number;
  16473. /**
  16474. * Sets the PCF or PCSS Quality.
  16475. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16476. */
  16477. set filteringQuality(filteringQuality: number);
  16478. /**
  16479. * Gets if the current filter is set to "PCSS" (contact hardening).
  16480. */
  16481. get useContactHardeningShadow(): boolean;
  16482. /**
  16483. * Sets the current filter to "PCSS" (contact hardening).
  16484. */
  16485. set useContactHardeningShadow(value: boolean);
  16486. protected _contactHardeningLightSizeUVRatio: number;
  16487. /**
  16488. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16489. * Using a ratio helps keeping shape stability independently of the map size.
  16490. *
  16491. * It does not account for the light projection as it was having too much
  16492. * instability during the light setup or during light position changes.
  16493. *
  16494. * Only valid if useContactHardeningShadow is true.
  16495. */
  16496. get contactHardeningLightSizeUVRatio(): number;
  16497. /**
  16498. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16499. * Using a ratio helps keeping shape stability independently of the map size.
  16500. *
  16501. * It does not account for the light projection as it was having too much
  16502. * instability during the light setup or during light position changes.
  16503. *
  16504. * Only valid if useContactHardeningShadow is true.
  16505. */
  16506. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16507. protected _darkness: number;
  16508. /** Gets or sets the actual darkness of a shadow */
  16509. get darkness(): number;
  16510. set darkness(value: number);
  16511. /**
  16512. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16513. * 0 means strongest and 1 would means no shadow.
  16514. * @returns the darkness.
  16515. */
  16516. getDarkness(): number;
  16517. /**
  16518. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16519. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16520. * @returns the shadow generator allowing fluent coding.
  16521. */
  16522. setDarkness(darkness: number): ShadowGenerator;
  16523. protected _transparencyShadow: boolean;
  16524. /** Gets or sets the ability to have transparent shadow */
  16525. get transparencyShadow(): boolean;
  16526. set transparencyShadow(value: boolean);
  16527. /**
  16528. * Sets the ability to have transparent shadow (boolean).
  16529. * @param transparent True if transparent else False
  16530. * @returns the shadow generator allowing fluent coding
  16531. */
  16532. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16533. protected _shadowMap: Nullable<RenderTargetTexture>;
  16534. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16535. /**
  16536. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16537. * @returns The render target texture if present otherwise, null
  16538. */
  16539. getShadowMap(): Nullable<RenderTargetTexture>;
  16540. /**
  16541. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16542. * @returns The render target texture if the shadow map is present otherwise, null
  16543. */
  16544. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16545. /**
  16546. * Gets the class name of that object
  16547. * @returns "ShadowGenerator"
  16548. */
  16549. getClassName(): string;
  16550. /**
  16551. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16552. * @param mesh Mesh to add
  16553. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16554. * @returns the Shadow Generator itself
  16555. */
  16556. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16557. /**
  16558. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16559. * @param mesh Mesh to remove
  16560. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16561. * @returns the Shadow Generator itself
  16562. */
  16563. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16564. /**
  16565. * Controls the extent to which the shadows fade out at the edge of the frustum
  16566. */
  16567. frustumEdgeFalloff: number;
  16568. protected _light: IShadowLight;
  16569. /**
  16570. * Returns the associated light object.
  16571. * @returns the light generating the shadow
  16572. */
  16573. getLight(): IShadowLight;
  16574. /**
  16575. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16576. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16577. * It might on the other hand introduce peter panning.
  16578. */
  16579. forceBackFacesOnly: boolean;
  16580. protected _scene: Scene;
  16581. protected _lightDirection: Vector3;
  16582. protected _effect: Effect;
  16583. protected _viewMatrix: Matrix;
  16584. protected _projectionMatrix: Matrix;
  16585. protected _transformMatrix: Matrix;
  16586. protected _cachedPosition: Vector3;
  16587. protected _cachedDirection: Vector3;
  16588. protected _cachedDefines: string;
  16589. protected _currentRenderID: number;
  16590. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16591. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16592. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16593. protected _blurPostProcesses: PostProcess[];
  16594. protected _mapSize: number;
  16595. protected _currentFaceIndex: number;
  16596. protected _currentFaceIndexCache: number;
  16597. protected _textureType: number;
  16598. protected _defaultTextureMatrix: Matrix;
  16599. protected _storedUniqueId: Nullable<number>;
  16600. /** @hidden */
  16601. static _SceneComponentInitialization: (scene: Scene) => void;
  16602. /**
  16603. * Creates a ShadowGenerator object.
  16604. * A ShadowGenerator is the required tool to use the shadows.
  16605. * Each light casting shadows needs to use its own ShadowGenerator.
  16606. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16607. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16608. * @param light The light object generating the shadows.
  16609. * @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.
  16610. */
  16611. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16612. protected _initializeGenerator(): void;
  16613. protected _createTargetRenderTexture(): void;
  16614. protected _initializeShadowMap(): void;
  16615. protected _initializeBlurRTTAndPostProcesses(): void;
  16616. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16617. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16618. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16619. protected _applyFilterValues(): void;
  16620. /**
  16621. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16622. * @param onCompiled Callback triggered at the and of the effects compilation
  16623. * @param options Sets of optional options forcing the compilation with different modes
  16624. */
  16625. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16626. useInstances: boolean;
  16627. }>): void;
  16628. /**
  16629. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16630. * @param options Sets of optional options forcing the compilation with different modes
  16631. * @returns A promise that resolves when the compilation completes
  16632. */
  16633. forceCompilationAsync(options?: Partial<{
  16634. useInstances: boolean;
  16635. }>): Promise<void>;
  16636. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16637. /**
  16638. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16639. * @param subMesh The submesh we want to render in the shadow map
  16640. * @param useInstances Defines wether will draw in the map using instances
  16641. * @returns true if ready otherwise, false
  16642. */
  16643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16644. /**
  16645. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16646. * @param defines Defines of the material we want to update
  16647. * @param lightIndex Index of the light in the enabled light list of the material
  16648. */
  16649. prepareDefines(defines: any, lightIndex: number): void;
  16650. /**
  16651. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16652. * defined in the generator but impacting the effect).
  16653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16654. * @param effect The effect we are binfing the information for
  16655. */
  16656. bindShadowLight(lightIndex: string, effect: Effect): void;
  16657. /**
  16658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16659. * (eq to shadow prjection matrix * light transform matrix)
  16660. * @returns The transform matrix used to create the shadow map
  16661. */
  16662. getTransformMatrix(): Matrix;
  16663. /**
  16664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16665. * Cube and 2D textures for instance.
  16666. */
  16667. recreateShadowMap(): void;
  16668. protected _disposeBlurPostProcesses(): void;
  16669. protected _disposeRTTandPostProcesses(): void;
  16670. /**
  16671. * Disposes the ShadowGenerator.
  16672. * Returns nothing.
  16673. */
  16674. dispose(): void;
  16675. /**
  16676. * Serializes the shadow generator setup to a json object.
  16677. * @returns The serialized JSON object
  16678. */
  16679. serialize(): any;
  16680. /**
  16681. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16682. * @param parsedShadowGenerator The JSON object to parse
  16683. * @param scene The scene to create the shadow map for
  16684. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16685. * @returns The parsed shadow generator
  16686. */
  16687. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16688. }
  16689. }
  16690. declare module BABYLON {
  16691. /**
  16692. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16693. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16694. * 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.
  16695. */
  16696. export abstract class Light extends Node {
  16697. /**
  16698. * Falloff Default: light is falling off following the material specification:
  16699. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16700. */
  16701. static readonly FALLOFF_DEFAULT: number;
  16702. /**
  16703. * Falloff Physical: light is falling off following the inverse squared distance law.
  16704. */
  16705. static readonly FALLOFF_PHYSICAL: number;
  16706. /**
  16707. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16708. * to enhance interoperability with other engines.
  16709. */
  16710. static readonly FALLOFF_GLTF: number;
  16711. /**
  16712. * Falloff Standard: light is falling off like in the standard material
  16713. * to enhance interoperability with other materials.
  16714. */
  16715. static readonly FALLOFF_STANDARD: number;
  16716. /**
  16717. * If every light affecting the material is in this lightmapMode,
  16718. * material.lightmapTexture adds or multiplies
  16719. * (depends on material.useLightmapAsShadowmap)
  16720. * after every other light calculations.
  16721. */
  16722. static readonly LIGHTMAP_DEFAULT: number;
  16723. /**
  16724. * material.lightmapTexture as only diffuse lighting from this light
  16725. * adds only specular lighting from this light
  16726. * adds dynamic shadows
  16727. */
  16728. static readonly LIGHTMAP_SPECULAR: number;
  16729. /**
  16730. * material.lightmapTexture as only lighting
  16731. * no light calculation from this light
  16732. * only adds dynamic shadows from this light
  16733. */
  16734. static readonly LIGHTMAP_SHADOWSONLY: number;
  16735. /**
  16736. * Each light type uses the default quantity according to its type:
  16737. * point/spot lights use luminous intensity
  16738. * directional lights use illuminance
  16739. */
  16740. static readonly INTENSITYMODE_AUTOMATIC: number;
  16741. /**
  16742. * lumen (lm)
  16743. */
  16744. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16745. /**
  16746. * candela (lm/sr)
  16747. */
  16748. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16749. /**
  16750. * lux (lm/m^2)
  16751. */
  16752. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16753. /**
  16754. * nit (cd/m^2)
  16755. */
  16756. static readonly INTENSITYMODE_LUMINANCE: number;
  16757. /**
  16758. * Light type const id of the point light.
  16759. */
  16760. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16761. /**
  16762. * Light type const id of the directional light.
  16763. */
  16764. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16765. /**
  16766. * Light type const id of the spot light.
  16767. */
  16768. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16769. /**
  16770. * Light type const id of the hemispheric light.
  16771. */
  16772. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16773. /**
  16774. * Diffuse gives the basic color to an object.
  16775. */
  16776. diffuse: Color3;
  16777. /**
  16778. * Specular produces a highlight color on an object.
  16779. * Note: This is note affecting PBR materials.
  16780. */
  16781. specular: Color3;
  16782. /**
  16783. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16784. * falling off base on range or angle.
  16785. * This can be set to any values in Light.FALLOFF_x.
  16786. *
  16787. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16788. * other types of materials.
  16789. */
  16790. falloffType: number;
  16791. /**
  16792. * Strength of the light.
  16793. * Note: By default it is define in the framework own unit.
  16794. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16795. */
  16796. intensity: number;
  16797. private _range;
  16798. protected _inverseSquaredRange: number;
  16799. /**
  16800. * Defines how far from the source the light is impacting in scene units.
  16801. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16802. */
  16803. get range(): number;
  16804. /**
  16805. * Defines how far from the source the light is impacting in scene units.
  16806. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16807. */
  16808. set range(value: number);
  16809. /**
  16810. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16811. * of light.
  16812. */
  16813. private _photometricScale;
  16814. private _intensityMode;
  16815. /**
  16816. * Gets the photometric scale used to interpret the intensity.
  16817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16818. */
  16819. get intensityMode(): number;
  16820. /**
  16821. * Sets the photometric scale used to interpret the intensity.
  16822. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16823. */
  16824. set intensityMode(value: number);
  16825. private _radius;
  16826. /**
  16827. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16828. */
  16829. get radius(): number;
  16830. /**
  16831. * sets the light radius used by PBR Materials to simulate soft area lights.
  16832. */
  16833. set radius(value: number);
  16834. private _renderPriority;
  16835. /**
  16836. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16837. * exceeding the number allowed of the materials.
  16838. */
  16839. renderPriority: number;
  16840. private _shadowEnabled;
  16841. /**
  16842. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16843. * the current shadow generator.
  16844. */
  16845. get shadowEnabled(): boolean;
  16846. /**
  16847. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16848. * the current shadow generator.
  16849. */
  16850. set shadowEnabled(value: boolean);
  16851. private _includedOnlyMeshes;
  16852. /**
  16853. * Gets the only meshes impacted by this light.
  16854. */
  16855. get includedOnlyMeshes(): AbstractMesh[];
  16856. /**
  16857. * Sets the only meshes impacted by this light.
  16858. */
  16859. set includedOnlyMeshes(value: AbstractMesh[]);
  16860. private _excludedMeshes;
  16861. /**
  16862. * Gets the meshes not impacted by this light.
  16863. */
  16864. get excludedMeshes(): AbstractMesh[];
  16865. /**
  16866. * Sets the meshes not impacted by this light.
  16867. */
  16868. set excludedMeshes(value: AbstractMesh[]);
  16869. private _excludeWithLayerMask;
  16870. /**
  16871. * Gets the layer id use to find what meshes are not impacted by the light.
  16872. * Inactive if 0
  16873. */
  16874. get excludeWithLayerMask(): number;
  16875. /**
  16876. * Sets the layer id use to find what meshes are not impacted by the light.
  16877. * Inactive if 0
  16878. */
  16879. set excludeWithLayerMask(value: number);
  16880. private _includeOnlyWithLayerMask;
  16881. /**
  16882. * Gets the layer id use to find what meshes are impacted by the light.
  16883. * Inactive if 0
  16884. */
  16885. get includeOnlyWithLayerMask(): number;
  16886. /**
  16887. * Sets the layer id use to find what meshes are impacted by the light.
  16888. * Inactive if 0
  16889. */
  16890. set includeOnlyWithLayerMask(value: number);
  16891. private _lightmapMode;
  16892. /**
  16893. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16894. */
  16895. get lightmapMode(): number;
  16896. /**
  16897. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16898. */
  16899. set lightmapMode(value: number);
  16900. /**
  16901. * Shadow generator associted to the light.
  16902. * @hidden Internal use only.
  16903. */
  16904. _shadowGenerator: Nullable<IShadowGenerator>;
  16905. /**
  16906. * @hidden Internal use only.
  16907. */
  16908. _excludedMeshesIds: string[];
  16909. /**
  16910. * @hidden Internal use only.
  16911. */
  16912. _includedOnlyMeshesIds: string[];
  16913. /**
  16914. * The current light unifom buffer.
  16915. * @hidden Internal use only.
  16916. */
  16917. _uniformBuffer: UniformBuffer;
  16918. /** @hidden */
  16919. _renderId: number;
  16920. /**
  16921. * Creates a Light object in the scene.
  16922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16923. * @param name The firendly name of the light
  16924. * @param scene The scene the light belongs too
  16925. */
  16926. constructor(name: string, scene: Scene);
  16927. protected abstract _buildUniformLayout(): void;
  16928. /**
  16929. * Sets the passed Effect "effect" with the Light information.
  16930. * @param effect The effect to update
  16931. * @param lightIndex The index of the light in the effect to update
  16932. * @returns The light
  16933. */
  16934. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16935. /**
  16936. * Sets the passed Effect "effect" with the Light textures.
  16937. * @param effect The effect to update
  16938. * @param lightIndex The index of the light in the effect to update
  16939. * @returns The light
  16940. */
  16941. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16942. /**
  16943. * Binds the lights information from the scene to the effect for the given mesh.
  16944. * @param lightIndex Light index
  16945. * @param scene The scene where the light belongs to
  16946. * @param effect The effect we are binding the data to
  16947. * @param useSpecular Defines if specular is supported
  16948. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16949. */
  16950. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16951. /**
  16952. * Sets the passed Effect "effect" with the Light information.
  16953. * @param effect The effect to update
  16954. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16955. * @returns The light
  16956. */
  16957. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16958. /**
  16959. * Returns the string "Light".
  16960. * @returns the class name
  16961. */
  16962. getClassName(): string;
  16963. /** @hidden */
  16964. readonly _isLight: boolean;
  16965. /**
  16966. * Converts the light information to a readable string for debug purpose.
  16967. * @param fullDetails Supports for multiple levels of logging within scene loading
  16968. * @returns the human readable light info
  16969. */
  16970. toString(fullDetails?: boolean): string;
  16971. /** @hidden */
  16972. protected _syncParentEnabledState(): void;
  16973. /**
  16974. * Set the enabled state of this node.
  16975. * @param value - the new enabled state
  16976. */
  16977. setEnabled(value: boolean): void;
  16978. /**
  16979. * Returns the Light associated shadow generator if any.
  16980. * @return the associated shadow generator.
  16981. */
  16982. getShadowGenerator(): Nullable<IShadowGenerator>;
  16983. /**
  16984. * Returns a Vector3, the absolute light position in the World.
  16985. * @returns the world space position of the light
  16986. */
  16987. getAbsolutePosition(): Vector3;
  16988. /**
  16989. * Specifies if the light will affect the passed mesh.
  16990. * @param mesh The mesh to test against the light
  16991. * @return true the mesh is affected otherwise, false.
  16992. */
  16993. canAffectMesh(mesh: AbstractMesh): boolean;
  16994. /**
  16995. * Sort function to order lights for rendering.
  16996. * @param a First Light object to compare to second.
  16997. * @param b Second Light object to compare first.
  16998. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16999. */
  17000. static CompareLightsPriority(a: Light, b: Light): number;
  17001. /**
  17002. * Releases resources associated with this node.
  17003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17005. */
  17006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17007. /**
  17008. * Returns the light type ID (integer).
  17009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17010. */
  17011. getTypeID(): number;
  17012. /**
  17013. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17014. * @returns the scaled intensity in intensity mode unit
  17015. */
  17016. getScaledIntensity(): number;
  17017. /**
  17018. * Returns a new Light object, named "name", from the current one.
  17019. * @param name The name of the cloned light
  17020. * @returns the new created light
  17021. */
  17022. clone(name: string): Nullable<Light>;
  17023. /**
  17024. * Serializes the current light into a Serialization object.
  17025. * @returns the serialized object.
  17026. */
  17027. serialize(): any;
  17028. /**
  17029. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17030. * This new light is named "name" and added to the passed scene.
  17031. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17032. * @param name The friendly name of the light
  17033. * @param scene The scene the new light will belong to
  17034. * @returns the constructor function
  17035. */
  17036. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17037. /**
  17038. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17039. * @param parsedLight The JSON representation of the light
  17040. * @param scene The scene to create the parsed light in
  17041. * @returns the created light after parsing
  17042. */
  17043. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17044. private _hookArrayForExcluded;
  17045. private _hookArrayForIncludedOnly;
  17046. private _resyncMeshes;
  17047. /**
  17048. * Forces the meshes to update their light related information in their rendering used effects
  17049. * @hidden Internal Use Only
  17050. */
  17051. _markMeshesAsLightDirty(): void;
  17052. /**
  17053. * Recomputes the cached photometric scale if needed.
  17054. */
  17055. private _computePhotometricScale;
  17056. /**
  17057. * Returns the Photometric Scale according to the light type and intensity mode.
  17058. */
  17059. private _getPhotometricScale;
  17060. /**
  17061. * Reorder the light in the scene according to their defined priority.
  17062. * @hidden Internal Use Only
  17063. */
  17064. _reorderLightsInScene(): void;
  17065. /**
  17066. * Prepares the list of defines specific to the light type.
  17067. * @param defines the list of defines
  17068. * @param lightIndex defines the index of the light for the effect
  17069. */
  17070. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17071. }
  17072. }
  17073. declare module BABYLON {
  17074. /**
  17075. * Interface used to define Action
  17076. */
  17077. export interface IAction {
  17078. /**
  17079. * Trigger for the action
  17080. */
  17081. trigger: number;
  17082. /** Options of the trigger */
  17083. triggerOptions: any;
  17084. /**
  17085. * Gets the trigger parameters
  17086. * @returns the trigger parameters
  17087. */
  17088. getTriggerParameter(): any;
  17089. /**
  17090. * Internal only - executes current action event
  17091. * @hidden
  17092. */
  17093. _executeCurrent(evt?: ActionEvent): void;
  17094. /**
  17095. * Serialize placeholder for child classes
  17096. * @param parent of child
  17097. * @returns the serialized object
  17098. */
  17099. serialize(parent: any): any;
  17100. /**
  17101. * Internal only
  17102. * @hidden
  17103. */
  17104. _prepare(): void;
  17105. /**
  17106. * Internal only - manager for action
  17107. * @hidden
  17108. */
  17109. _actionManager: AbstractActionManager;
  17110. /**
  17111. * Adds action to chain of actions, may be a DoNothingAction
  17112. * @param action defines the next action to execute
  17113. * @returns The action passed in
  17114. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17115. */
  17116. then(action: IAction): IAction;
  17117. }
  17118. /**
  17119. * The action to be carried out following a trigger
  17120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17121. */
  17122. export class Action implements IAction {
  17123. /** the trigger, with or without parameters, for the action */
  17124. triggerOptions: any;
  17125. /**
  17126. * Trigger for the action
  17127. */
  17128. trigger: number;
  17129. /**
  17130. * Internal only - manager for action
  17131. * @hidden
  17132. */
  17133. _actionManager: ActionManager;
  17134. private _nextActiveAction;
  17135. private _child;
  17136. private _condition?;
  17137. private _triggerParameter;
  17138. /**
  17139. * An event triggered prior to action being executed.
  17140. */
  17141. onBeforeExecuteObservable: Observable<Action>;
  17142. /**
  17143. * Creates a new Action
  17144. * @param triggerOptions the trigger, with or without parameters, for the action
  17145. * @param condition an optional determinant of action
  17146. */
  17147. constructor(
  17148. /** the trigger, with or without parameters, for the action */
  17149. triggerOptions: any, condition?: Condition);
  17150. /**
  17151. * Internal only
  17152. * @hidden
  17153. */
  17154. _prepare(): void;
  17155. /**
  17156. * Gets the trigger parameters
  17157. * @returns the trigger parameters
  17158. */
  17159. getTriggerParameter(): any;
  17160. /**
  17161. * Internal only - executes current action event
  17162. * @hidden
  17163. */
  17164. _executeCurrent(evt?: ActionEvent): void;
  17165. /**
  17166. * Execute placeholder for child classes
  17167. * @param evt optional action event
  17168. */
  17169. execute(evt?: ActionEvent): void;
  17170. /**
  17171. * Skips to next active action
  17172. */
  17173. skipToNextActiveAction(): void;
  17174. /**
  17175. * Adds action to chain of actions, may be a DoNothingAction
  17176. * @param action defines the next action to execute
  17177. * @returns The action passed in
  17178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17179. */
  17180. then(action: Action): Action;
  17181. /**
  17182. * Internal only
  17183. * @hidden
  17184. */
  17185. _getProperty(propertyPath: string): string;
  17186. /**
  17187. * Internal only
  17188. * @hidden
  17189. */
  17190. _getEffectiveTarget(target: any, propertyPath: string): any;
  17191. /**
  17192. * Serialize placeholder for child classes
  17193. * @param parent of child
  17194. * @returns the serialized object
  17195. */
  17196. serialize(parent: any): any;
  17197. /**
  17198. * Internal only called by serialize
  17199. * @hidden
  17200. */
  17201. protected _serialize(serializedAction: any, parent?: any): any;
  17202. /**
  17203. * Internal only
  17204. * @hidden
  17205. */
  17206. static _SerializeValueAsString: (value: any) => string;
  17207. /**
  17208. * Internal only
  17209. * @hidden
  17210. */
  17211. static _GetTargetProperty: (target: Node | Scene) => {
  17212. name: string;
  17213. targetType: string;
  17214. value: string;
  17215. };
  17216. }
  17217. }
  17218. declare module BABYLON {
  17219. /**
  17220. * A Condition applied to an Action
  17221. */
  17222. export class Condition {
  17223. /**
  17224. * Internal only - manager for action
  17225. * @hidden
  17226. */
  17227. _actionManager: ActionManager;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. _evaluationId: number;
  17233. /**
  17234. * Internal only
  17235. * @hidden
  17236. */
  17237. _currentResult: boolean;
  17238. /**
  17239. * Creates a new Condition
  17240. * @param actionManager the manager of the action the condition is applied to
  17241. */
  17242. constructor(actionManager: ActionManager);
  17243. /**
  17244. * Check if the current condition is valid
  17245. * @returns a boolean
  17246. */
  17247. isValid(): boolean;
  17248. /**
  17249. * Internal only
  17250. * @hidden
  17251. */
  17252. _getProperty(propertyPath: string): string;
  17253. /**
  17254. * Internal only
  17255. * @hidden
  17256. */
  17257. _getEffectiveTarget(target: any, propertyPath: string): any;
  17258. /**
  17259. * Serialize placeholder for child classes
  17260. * @returns the serialized object
  17261. */
  17262. serialize(): any;
  17263. /**
  17264. * Internal only
  17265. * @hidden
  17266. */
  17267. protected _serialize(serializedCondition: any): any;
  17268. }
  17269. /**
  17270. * Defines specific conditional operators as extensions of Condition
  17271. */
  17272. export class ValueCondition extends Condition {
  17273. /** path to specify the property of the target the conditional operator uses */
  17274. propertyPath: string;
  17275. /** the value compared by the conditional operator against the current value of the property */
  17276. value: any;
  17277. /** the conditional operator, default ValueCondition.IsEqual */
  17278. operator: number;
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. private static _IsEqual;
  17284. /**
  17285. * Internal only
  17286. * @hidden
  17287. */
  17288. private static _IsDifferent;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. private static _IsGreater;
  17294. /**
  17295. * Internal only
  17296. * @hidden
  17297. */
  17298. private static _IsLesser;
  17299. /**
  17300. * returns the number for IsEqual
  17301. */
  17302. static get IsEqual(): number;
  17303. /**
  17304. * Returns the number for IsDifferent
  17305. */
  17306. static get IsDifferent(): number;
  17307. /**
  17308. * Returns the number for IsGreater
  17309. */
  17310. static get IsGreater(): number;
  17311. /**
  17312. * Returns the number for IsLesser
  17313. */
  17314. static get IsLesser(): number;
  17315. /**
  17316. * Internal only The action manager for the condition
  17317. * @hidden
  17318. */
  17319. _actionManager: ActionManager;
  17320. /**
  17321. * Internal only
  17322. * @hidden
  17323. */
  17324. private _target;
  17325. /**
  17326. * Internal only
  17327. * @hidden
  17328. */
  17329. private _effectiveTarget;
  17330. /**
  17331. * Internal only
  17332. * @hidden
  17333. */
  17334. private _property;
  17335. /**
  17336. * Creates a new ValueCondition
  17337. * @param actionManager manager for the action the condition applies to
  17338. * @param target for the action
  17339. * @param propertyPath path to specify the property of the target the conditional operator uses
  17340. * @param value the value compared by the conditional operator against the current value of the property
  17341. * @param operator the conditional operator, default ValueCondition.IsEqual
  17342. */
  17343. constructor(actionManager: ActionManager, target: any,
  17344. /** path to specify the property of the target the conditional operator uses */
  17345. propertyPath: string,
  17346. /** the value compared by the conditional operator against the current value of the property */
  17347. value: any,
  17348. /** the conditional operator, default ValueCondition.IsEqual */
  17349. operator?: number);
  17350. /**
  17351. * Compares the given value with the property value for the specified conditional operator
  17352. * @returns the result of the comparison
  17353. */
  17354. isValid(): boolean;
  17355. /**
  17356. * Serialize the ValueCondition into a JSON compatible object
  17357. * @returns serialization object
  17358. */
  17359. serialize(): any;
  17360. /**
  17361. * Gets the name of the conditional operator for the ValueCondition
  17362. * @param operator the conditional operator
  17363. * @returns the name
  17364. */
  17365. static GetOperatorName(operator: number): string;
  17366. }
  17367. /**
  17368. * Defines a predicate condition as an extension of Condition
  17369. */
  17370. export class PredicateCondition extends Condition {
  17371. /** defines the predicate function used to validate the condition */
  17372. predicate: () => boolean;
  17373. /**
  17374. * Internal only - manager for action
  17375. * @hidden
  17376. */
  17377. _actionManager: ActionManager;
  17378. /**
  17379. * Creates a new PredicateCondition
  17380. * @param actionManager manager for the action the condition applies to
  17381. * @param predicate defines the predicate function used to validate the condition
  17382. */
  17383. constructor(actionManager: ActionManager,
  17384. /** defines the predicate function used to validate the condition */
  17385. predicate: () => boolean);
  17386. /**
  17387. * @returns the validity of the predicate condition
  17388. */
  17389. isValid(): boolean;
  17390. }
  17391. /**
  17392. * Defines a state condition as an extension of Condition
  17393. */
  17394. export class StateCondition extends Condition {
  17395. /** Value to compare with target state */
  17396. value: string;
  17397. /**
  17398. * Internal only - manager for action
  17399. * @hidden
  17400. */
  17401. _actionManager: ActionManager;
  17402. /**
  17403. * Internal only
  17404. * @hidden
  17405. */
  17406. private _target;
  17407. /**
  17408. * Creates a new StateCondition
  17409. * @param actionManager manager for the action the condition applies to
  17410. * @param target of the condition
  17411. * @param value to compare with target state
  17412. */
  17413. constructor(actionManager: ActionManager, target: any,
  17414. /** Value to compare with target state */
  17415. value: string);
  17416. /**
  17417. * Gets a boolean indicating if the current condition is met
  17418. * @returns the validity of the state
  17419. */
  17420. isValid(): boolean;
  17421. /**
  17422. * Serialize the StateCondition into a JSON compatible object
  17423. * @returns serialization object
  17424. */
  17425. serialize(): any;
  17426. }
  17427. }
  17428. declare module BABYLON {
  17429. /**
  17430. * This defines an action responsible to toggle a boolean once triggered.
  17431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17432. */
  17433. export class SwitchBooleanAction extends Action {
  17434. /**
  17435. * The path to the boolean property in the target object
  17436. */
  17437. propertyPath: string;
  17438. private _target;
  17439. private _effectiveTarget;
  17440. private _property;
  17441. /**
  17442. * Instantiate the action
  17443. * @param triggerOptions defines the trigger options
  17444. * @param target defines the object containing the boolean
  17445. * @param propertyPath defines the path to the boolean property in the target object
  17446. * @param condition defines the trigger related conditions
  17447. */
  17448. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17449. /** @hidden */
  17450. _prepare(): void;
  17451. /**
  17452. * Execute the action toggle the boolean value.
  17453. */
  17454. execute(): void;
  17455. /**
  17456. * Serializes the actions and its related information.
  17457. * @param parent defines the object to serialize in
  17458. * @returns the serialized object
  17459. */
  17460. serialize(parent: any): any;
  17461. }
  17462. /**
  17463. * This defines an action responsible to set a the state field of the target
  17464. * to a desired value once triggered.
  17465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17466. */
  17467. export class SetStateAction extends Action {
  17468. /**
  17469. * The value to store in the state field.
  17470. */
  17471. value: string;
  17472. private _target;
  17473. /**
  17474. * Instantiate the action
  17475. * @param triggerOptions defines the trigger options
  17476. * @param target defines the object containing the state property
  17477. * @param value defines the value to store in the state field
  17478. * @param condition defines the trigger related conditions
  17479. */
  17480. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17481. /**
  17482. * Execute the action and store the value on the target state property.
  17483. */
  17484. execute(): void;
  17485. /**
  17486. * Serializes the actions and its related information.
  17487. * @param parent defines the object to serialize in
  17488. * @returns the serialized object
  17489. */
  17490. serialize(parent: any): any;
  17491. }
  17492. /**
  17493. * This defines an action responsible to set a property of the target
  17494. * to a desired value once triggered.
  17495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17496. */
  17497. export class SetValueAction extends Action {
  17498. /**
  17499. * The path of the property to set in the target.
  17500. */
  17501. propertyPath: string;
  17502. /**
  17503. * The value to set in the property
  17504. */
  17505. value: any;
  17506. private _target;
  17507. private _effectiveTarget;
  17508. private _property;
  17509. /**
  17510. * Instantiate the action
  17511. * @param triggerOptions defines the trigger options
  17512. * @param target defines the object containing the property
  17513. * @param propertyPath defines the path of the property to set in the target
  17514. * @param value defines the value to set in the property
  17515. * @param condition defines the trigger related conditions
  17516. */
  17517. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17518. /** @hidden */
  17519. _prepare(): void;
  17520. /**
  17521. * Execute the action and set the targetted property to the desired value.
  17522. */
  17523. execute(): void;
  17524. /**
  17525. * Serializes the actions and its related information.
  17526. * @param parent defines the object to serialize in
  17527. * @returns the serialized object
  17528. */
  17529. serialize(parent: any): any;
  17530. }
  17531. /**
  17532. * This defines an action responsible to increment the target value
  17533. * to a desired value once triggered.
  17534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17535. */
  17536. export class IncrementValueAction extends Action {
  17537. /**
  17538. * The path of the property to increment in the target.
  17539. */
  17540. propertyPath: string;
  17541. /**
  17542. * The value we should increment the property by.
  17543. */
  17544. value: any;
  17545. private _target;
  17546. private _effectiveTarget;
  17547. private _property;
  17548. /**
  17549. * Instantiate the action
  17550. * @param triggerOptions defines the trigger options
  17551. * @param target defines the object containing the property
  17552. * @param propertyPath defines the path of the property to increment in the target
  17553. * @param value defines the value value we should increment the property by
  17554. * @param condition defines the trigger related conditions
  17555. */
  17556. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17557. /** @hidden */
  17558. _prepare(): void;
  17559. /**
  17560. * Execute the action and increment the target of the value amount.
  17561. */
  17562. execute(): void;
  17563. /**
  17564. * Serializes the actions and its related information.
  17565. * @param parent defines the object to serialize in
  17566. * @returns the serialized object
  17567. */
  17568. serialize(parent: any): any;
  17569. }
  17570. /**
  17571. * This defines an action responsible to start an animation once triggered.
  17572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17573. */
  17574. export class PlayAnimationAction extends Action {
  17575. /**
  17576. * Where the animation should start (animation frame)
  17577. */
  17578. from: number;
  17579. /**
  17580. * Where the animation should stop (animation frame)
  17581. */
  17582. to: number;
  17583. /**
  17584. * Define if the animation should loop or stop after the first play.
  17585. */
  17586. loop?: boolean;
  17587. private _target;
  17588. /**
  17589. * Instantiate the action
  17590. * @param triggerOptions defines the trigger options
  17591. * @param target defines the target animation or animation name
  17592. * @param from defines from where the animation should start (animation frame)
  17593. * @param end defines where the animation should stop (animation frame)
  17594. * @param loop defines if the animation should loop or stop after the first play
  17595. * @param condition defines the trigger related conditions
  17596. */
  17597. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17598. /** @hidden */
  17599. _prepare(): void;
  17600. /**
  17601. * Execute the action and play the animation.
  17602. */
  17603. execute(): void;
  17604. /**
  17605. * Serializes the actions and its related information.
  17606. * @param parent defines the object to serialize in
  17607. * @returns the serialized object
  17608. */
  17609. serialize(parent: any): any;
  17610. }
  17611. /**
  17612. * This defines an action responsible to stop an animation once triggered.
  17613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17614. */
  17615. export class StopAnimationAction extends Action {
  17616. private _target;
  17617. /**
  17618. * Instantiate the action
  17619. * @param triggerOptions defines the trigger options
  17620. * @param target defines the target animation or animation name
  17621. * @param condition defines the trigger related conditions
  17622. */
  17623. constructor(triggerOptions: any, target: any, condition?: Condition);
  17624. /** @hidden */
  17625. _prepare(): void;
  17626. /**
  17627. * Execute the action and stop the animation.
  17628. */
  17629. execute(): void;
  17630. /**
  17631. * Serializes the actions and its related information.
  17632. * @param parent defines the object to serialize in
  17633. * @returns the serialized object
  17634. */
  17635. serialize(parent: any): any;
  17636. }
  17637. /**
  17638. * This defines an action responsible that does nothing once triggered.
  17639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17640. */
  17641. export class DoNothingAction extends Action {
  17642. /**
  17643. * Instantiate the action
  17644. * @param triggerOptions defines the trigger options
  17645. * @param condition defines the trigger related conditions
  17646. */
  17647. constructor(triggerOptions?: any, condition?: Condition);
  17648. /**
  17649. * Execute the action and do nothing.
  17650. */
  17651. execute(): void;
  17652. /**
  17653. * Serializes the actions and its related information.
  17654. * @param parent defines the object to serialize in
  17655. * @returns the serialized object
  17656. */
  17657. serialize(parent: any): any;
  17658. }
  17659. /**
  17660. * This defines an action responsible to trigger several actions once triggered.
  17661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17662. */
  17663. export class CombineAction extends Action {
  17664. /**
  17665. * The list of aggregated animations to run.
  17666. */
  17667. children: Action[];
  17668. /**
  17669. * Instantiate the action
  17670. * @param triggerOptions defines the trigger options
  17671. * @param children defines the list of aggregated animations to run
  17672. * @param condition defines the trigger related conditions
  17673. */
  17674. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17675. /** @hidden */
  17676. _prepare(): void;
  17677. /**
  17678. * Execute the action and executes all the aggregated actions.
  17679. */
  17680. execute(evt: ActionEvent): void;
  17681. /**
  17682. * Serializes the actions and its related information.
  17683. * @param parent defines the object to serialize in
  17684. * @returns the serialized object
  17685. */
  17686. serialize(parent: any): any;
  17687. }
  17688. /**
  17689. * This defines an action responsible to run code (external event) once triggered.
  17690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17691. */
  17692. export class ExecuteCodeAction extends Action {
  17693. /**
  17694. * The callback function to run.
  17695. */
  17696. func: (evt: ActionEvent) => void;
  17697. /**
  17698. * Instantiate the action
  17699. * @param triggerOptions defines the trigger options
  17700. * @param func defines the callback function to run
  17701. * @param condition defines the trigger related conditions
  17702. */
  17703. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17704. /**
  17705. * Execute the action and run the attached code.
  17706. */
  17707. execute(evt: ActionEvent): void;
  17708. }
  17709. /**
  17710. * This defines an action responsible to set the parent property of the target once triggered.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class SetParentAction extends Action {
  17714. private _parent;
  17715. private _target;
  17716. /**
  17717. * Instantiate the action
  17718. * @param triggerOptions defines the trigger options
  17719. * @param target defines the target containing the parent property
  17720. * @param parent defines from where the animation should start (animation frame)
  17721. * @param condition defines the trigger related conditions
  17722. */
  17723. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17724. /** @hidden */
  17725. _prepare(): void;
  17726. /**
  17727. * Execute the action and set the parent property.
  17728. */
  17729. execute(): void;
  17730. /**
  17731. * Serializes the actions and its related information.
  17732. * @param parent defines the object to serialize in
  17733. * @returns the serialized object
  17734. */
  17735. serialize(parent: any): any;
  17736. }
  17737. }
  17738. declare module BABYLON {
  17739. /**
  17740. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17741. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17743. */
  17744. export class ActionManager extends AbstractActionManager {
  17745. /**
  17746. * Nothing
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17748. */
  17749. static readonly NothingTrigger: number;
  17750. /**
  17751. * On pick
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnPickTrigger: number;
  17755. /**
  17756. * On left pick
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnLeftPickTrigger: number;
  17760. /**
  17761. * On right pick
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnRightPickTrigger: number;
  17765. /**
  17766. * On center pick
  17767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17768. */
  17769. static readonly OnCenterPickTrigger: number;
  17770. /**
  17771. * On pick down
  17772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17773. */
  17774. static readonly OnPickDownTrigger: number;
  17775. /**
  17776. * On double pick
  17777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17778. */
  17779. static readonly OnDoublePickTrigger: number;
  17780. /**
  17781. * On pick up
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17783. */
  17784. static readonly OnPickUpTrigger: number;
  17785. /**
  17786. * On pick out.
  17787. * This trigger will only be raised if you also declared a OnPickDown
  17788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17789. */
  17790. static readonly OnPickOutTrigger: number;
  17791. /**
  17792. * On long press
  17793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17794. */
  17795. static readonly OnLongPressTrigger: number;
  17796. /**
  17797. * On pointer over
  17798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17799. */
  17800. static readonly OnPointerOverTrigger: number;
  17801. /**
  17802. * On pointer out
  17803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17804. */
  17805. static readonly OnPointerOutTrigger: number;
  17806. /**
  17807. * On every frame
  17808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17809. */
  17810. static readonly OnEveryFrameTrigger: number;
  17811. /**
  17812. * On intersection enter
  17813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17814. */
  17815. static readonly OnIntersectionEnterTrigger: number;
  17816. /**
  17817. * On intersection exit
  17818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17819. */
  17820. static readonly OnIntersectionExitTrigger: number;
  17821. /**
  17822. * On key down
  17823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17824. */
  17825. static readonly OnKeyDownTrigger: number;
  17826. /**
  17827. * On key up
  17828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17829. */
  17830. static readonly OnKeyUpTrigger: number;
  17831. private _scene;
  17832. /**
  17833. * Creates a new action manager
  17834. * @param scene defines the hosting scene
  17835. */
  17836. constructor(scene: Scene);
  17837. /**
  17838. * Releases all associated resources
  17839. */
  17840. dispose(): void;
  17841. /**
  17842. * Gets hosting scene
  17843. * @returns the hosting scene
  17844. */
  17845. getScene(): Scene;
  17846. /**
  17847. * Does this action manager handles actions of any of the given triggers
  17848. * @param triggers defines the triggers to be tested
  17849. * @return a boolean indicating whether one (or more) of the triggers is handled
  17850. */
  17851. hasSpecificTriggers(triggers: number[]): boolean;
  17852. /**
  17853. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17854. * speed.
  17855. * @param triggerA defines the trigger to be tested
  17856. * @param triggerB defines the trigger to be tested
  17857. * @return a boolean indicating whether one (or more) of the triggers is handled
  17858. */
  17859. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17860. /**
  17861. * Does this action manager handles actions of a given trigger
  17862. * @param trigger defines the trigger to be tested
  17863. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17864. * @return whether the trigger is handled
  17865. */
  17866. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17867. /**
  17868. * Does this action manager has pointer triggers
  17869. */
  17870. get hasPointerTriggers(): boolean;
  17871. /**
  17872. * Does this action manager has pick triggers
  17873. */
  17874. get hasPickTriggers(): boolean;
  17875. /**
  17876. * Registers an action to this action manager
  17877. * @param action defines the action to be registered
  17878. * @return the action amended (prepared) after registration
  17879. */
  17880. registerAction(action: IAction): Nullable<IAction>;
  17881. /**
  17882. * Unregisters an action to this action manager
  17883. * @param action defines the action to be unregistered
  17884. * @return a boolean indicating whether the action has been unregistered
  17885. */
  17886. unregisterAction(action: IAction): Boolean;
  17887. /**
  17888. * Process a specific trigger
  17889. * @param trigger defines the trigger to process
  17890. * @param evt defines the event details to be processed
  17891. */
  17892. processTrigger(trigger: number, evt?: IActionEvent): void;
  17893. /** @hidden */
  17894. _getEffectiveTarget(target: any, propertyPath: string): any;
  17895. /** @hidden */
  17896. _getProperty(propertyPath: string): string;
  17897. /**
  17898. * Serialize this manager to a JSON object
  17899. * @param name defines the property name to store this manager
  17900. * @returns a JSON representation of this manager
  17901. */
  17902. serialize(name: string): any;
  17903. /**
  17904. * Creates a new ActionManager from a JSON data
  17905. * @param parsedActions defines the JSON data to read from
  17906. * @param object defines the hosting mesh
  17907. * @param scene defines the hosting scene
  17908. */
  17909. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17910. /**
  17911. * Get a trigger name by index
  17912. * @param trigger defines the trigger index
  17913. * @returns a trigger name
  17914. */
  17915. static GetTriggerName(trigger: number): string;
  17916. }
  17917. }
  17918. declare module BABYLON {
  17919. /**
  17920. * Class used to represent a sprite
  17921. * @see http://doc.babylonjs.com/babylon101/sprites
  17922. */
  17923. export class Sprite {
  17924. /** defines the name */
  17925. name: string;
  17926. /** Gets or sets the current world position */
  17927. position: Vector3;
  17928. /** Gets or sets the main color */
  17929. color: Color4;
  17930. /** Gets or sets the width */
  17931. width: number;
  17932. /** Gets or sets the height */
  17933. height: number;
  17934. /** Gets or sets rotation angle */
  17935. angle: number;
  17936. /** Gets or sets the cell index in the sprite sheet */
  17937. cellIndex: number;
  17938. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17939. cellRef: string;
  17940. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17941. invertU: number;
  17942. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17943. invertV: number;
  17944. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17945. disposeWhenFinishedAnimating: boolean;
  17946. /** Gets the list of attached animations */
  17947. animations: Animation[];
  17948. /** Gets or sets a boolean indicating if the sprite can be picked */
  17949. isPickable: boolean;
  17950. /**
  17951. * Gets or sets the associated action manager
  17952. */
  17953. actionManager: Nullable<ActionManager>;
  17954. private _animationStarted;
  17955. private _loopAnimation;
  17956. private _fromIndex;
  17957. private _toIndex;
  17958. private _delay;
  17959. private _direction;
  17960. private _manager;
  17961. private _time;
  17962. private _onAnimationEnd;
  17963. /**
  17964. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17965. */
  17966. isVisible: boolean;
  17967. /**
  17968. * Gets or sets the sprite size
  17969. */
  17970. get size(): number;
  17971. set size(value: number);
  17972. /**
  17973. * Creates a new Sprite
  17974. * @param name defines the name
  17975. * @param manager defines the manager
  17976. */
  17977. constructor(
  17978. /** defines the name */
  17979. name: string, manager: ISpriteManager);
  17980. /**
  17981. * Starts an animation
  17982. * @param from defines the initial key
  17983. * @param to defines the end key
  17984. * @param loop defines if the animation must loop
  17985. * @param delay defines the start delay (in ms)
  17986. * @param onAnimationEnd defines a callback to call when animation ends
  17987. */
  17988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17989. /** Stops current animation (if any) */
  17990. stopAnimation(): void;
  17991. /** @hidden */
  17992. _animate(deltaTime: number): void;
  17993. /** Release associated resources */
  17994. dispose(): void;
  17995. }
  17996. }
  17997. declare module BABYLON {
  17998. /**
  17999. * Information about the result of picking within a scene
  18000. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18001. */
  18002. export class PickingInfo {
  18003. /** @hidden */
  18004. _pickingUnavailable: boolean;
  18005. /**
  18006. * If the pick collided with an object
  18007. */
  18008. hit: boolean;
  18009. /**
  18010. * Distance away where the pick collided
  18011. */
  18012. distance: number;
  18013. /**
  18014. * The location of pick collision
  18015. */
  18016. pickedPoint: Nullable<Vector3>;
  18017. /**
  18018. * The mesh corresponding the the pick collision
  18019. */
  18020. pickedMesh: Nullable<AbstractMesh>;
  18021. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18022. bu: number;
  18023. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18024. bv: number;
  18025. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18026. faceId: number;
  18027. /** Id of the the submesh that was picked */
  18028. subMeshId: number;
  18029. /** If a sprite was picked, this will be the sprite the pick collided with */
  18030. pickedSprite: Nullable<Sprite>;
  18031. /**
  18032. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18033. */
  18034. originMesh: Nullable<AbstractMesh>;
  18035. /**
  18036. * The ray that was used to perform the picking.
  18037. */
  18038. ray: Nullable<Ray>;
  18039. /**
  18040. * Gets the normal correspodning to the face the pick collided with
  18041. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18042. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18043. * @returns The normal correspodning to the face the pick collided with
  18044. */
  18045. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18046. /**
  18047. * Gets the texture coordinates of where the pick occured
  18048. * @returns the vector containing the coordnates of the texture
  18049. */
  18050. getTextureCoordinates(): Nullable<Vector2>;
  18051. }
  18052. }
  18053. declare module BABYLON {
  18054. /**
  18055. * Gather the list of pointer event types as constants.
  18056. */
  18057. export class PointerEventTypes {
  18058. /**
  18059. * 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.
  18060. */
  18061. static readonly POINTERDOWN: number;
  18062. /**
  18063. * The pointerup event is fired when a pointer is no longer active.
  18064. */
  18065. static readonly POINTERUP: number;
  18066. /**
  18067. * The pointermove event is fired when a pointer changes coordinates.
  18068. */
  18069. static readonly POINTERMOVE: number;
  18070. /**
  18071. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18072. */
  18073. static readonly POINTERWHEEL: number;
  18074. /**
  18075. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18076. */
  18077. static readonly POINTERPICK: number;
  18078. /**
  18079. * The pointertap event is fired when a the object has been touched and released without drag.
  18080. */
  18081. static readonly POINTERTAP: number;
  18082. /**
  18083. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18084. */
  18085. static readonly POINTERDOUBLETAP: number;
  18086. }
  18087. /**
  18088. * Base class of pointer info types.
  18089. */
  18090. export class PointerInfoBase {
  18091. /**
  18092. * Defines the type of event (PointerEventTypes)
  18093. */
  18094. type: number;
  18095. /**
  18096. * Defines the related dom event
  18097. */
  18098. event: PointerEvent | MouseWheelEvent;
  18099. /**
  18100. * Instantiates the base class of pointers info.
  18101. * @param type Defines the type of event (PointerEventTypes)
  18102. * @param event Defines the related dom event
  18103. */
  18104. constructor(
  18105. /**
  18106. * Defines the type of event (PointerEventTypes)
  18107. */
  18108. type: number,
  18109. /**
  18110. * Defines the related dom event
  18111. */
  18112. event: PointerEvent | MouseWheelEvent);
  18113. }
  18114. /**
  18115. * This class is used to store pointer related info for the onPrePointerObservable event.
  18116. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18117. */
  18118. export class PointerInfoPre extends PointerInfoBase {
  18119. /**
  18120. * Ray from a pointer if availible (eg. 6dof controller)
  18121. */
  18122. ray: Nullable<Ray>;
  18123. /**
  18124. * Defines the local position of the pointer on the canvas.
  18125. */
  18126. localPosition: Vector2;
  18127. /**
  18128. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18129. */
  18130. skipOnPointerObservable: boolean;
  18131. /**
  18132. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18133. * @param type Defines the type of event (PointerEventTypes)
  18134. * @param event Defines the related dom event
  18135. * @param localX Defines the local x coordinates of the pointer when the event occured
  18136. * @param localY Defines the local y coordinates of the pointer when the event occured
  18137. */
  18138. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18139. }
  18140. /**
  18141. * This type contains all the data related to a pointer event in Babylon.js.
  18142. * 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.
  18143. */
  18144. export class PointerInfo extends PointerInfoBase {
  18145. /**
  18146. * Defines the picking info associated to the info (if any)\
  18147. */
  18148. pickInfo: Nullable<PickingInfo>;
  18149. /**
  18150. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18151. * @param type Defines the type of event (PointerEventTypes)
  18152. * @param event Defines the related dom event
  18153. * @param pickInfo Defines the picking info associated to the info (if any)\
  18154. */
  18155. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18156. /**
  18157. * Defines the picking info associated to the info (if any)\
  18158. */
  18159. pickInfo: Nullable<PickingInfo>);
  18160. }
  18161. /**
  18162. * Data relating to a touch event on the screen.
  18163. */
  18164. export interface PointerTouch {
  18165. /**
  18166. * X coordinate of touch.
  18167. */
  18168. x: number;
  18169. /**
  18170. * Y coordinate of touch.
  18171. */
  18172. y: number;
  18173. /**
  18174. * Id of touch. Unique for each finger.
  18175. */
  18176. pointerId: number;
  18177. /**
  18178. * Event type passed from DOM.
  18179. */
  18180. type: any;
  18181. }
  18182. }
  18183. declare module BABYLON {
  18184. /**
  18185. * Manage the mouse inputs to control the movement of a free camera.
  18186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18187. */
  18188. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18189. /**
  18190. * Define if touch is enabled in the mouse input
  18191. */
  18192. touchEnabled: boolean;
  18193. /**
  18194. * Defines the camera the input is attached to.
  18195. */
  18196. camera: FreeCamera;
  18197. /**
  18198. * Defines the buttons associated with the input to handle camera move.
  18199. */
  18200. buttons: number[];
  18201. /**
  18202. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18203. */
  18204. angularSensibility: number;
  18205. private _pointerInput;
  18206. private _onMouseMove;
  18207. private _observer;
  18208. private previousPosition;
  18209. /**
  18210. * Observable for when a pointer move event occurs containing the move offset
  18211. */
  18212. onPointerMovedObservable: Observable<{
  18213. offsetX: number;
  18214. offsetY: number;
  18215. }>;
  18216. /**
  18217. * @hidden
  18218. * If the camera should be rotated automatically based on pointer movement
  18219. */
  18220. _allowCameraRotation: boolean;
  18221. /**
  18222. * Manage the mouse inputs to control the movement of a free camera.
  18223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18224. * @param touchEnabled Defines if touch is enabled or not
  18225. */
  18226. constructor(
  18227. /**
  18228. * Define if touch is enabled in the mouse input
  18229. */
  18230. touchEnabled?: boolean);
  18231. /**
  18232. * Attach the input controls to a specific dom element to get the input from.
  18233. * @param element Defines the element the controls should be listened from
  18234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18235. */
  18236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18237. /**
  18238. * Called on JS contextmenu event.
  18239. * Override this method to provide functionality.
  18240. */
  18241. protected onContextMenu(evt: PointerEvent): void;
  18242. /**
  18243. * Detach the current controls from the specified dom element.
  18244. * @param element Defines the element to stop listening the inputs from
  18245. */
  18246. detachControl(element: Nullable<HTMLElement>): void;
  18247. /**
  18248. * Gets the class name of the current intput.
  18249. * @returns the class name
  18250. */
  18251. getClassName(): string;
  18252. /**
  18253. * Get the friendly name associated with the input class.
  18254. * @returns the input friendly name
  18255. */
  18256. getSimpleName(): string;
  18257. }
  18258. }
  18259. declare module BABYLON {
  18260. /**
  18261. * Manage the touch inputs to control the movement of a free camera.
  18262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18263. */
  18264. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18265. /**
  18266. * Defines the camera the input is attached to.
  18267. */
  18268. camera: FreeCamera;
  18269. /**
  18270. * Defines the touch sensibility for rotation.
  18271. * The higher the faster.
  18272. */
  18273. touchAngularSensibility: number;
  18274. /**
  18275. * Defines the touch sensibility for move.
  18276. * The higher the faster.
  18277. */
  18278. touchMoveSensibility: number;
  18279. private _offsetX;
  18280. private _offsetY;
  18281. private _pointerPressed;
  18282. private _pointerInput;
  18283. private _observer;
  18284. private _onLostFocus;
  18285. /**
  18286. * Attach the input controls to a specific dom element to get the input from.
  18287. * @param element Defines the element the controls should be listened from
  18288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18289. */
  18290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18291. /**
  18292. * Detach the current controls from the specified dom element.
  18293. * @param element Defines the element to stop listening the inputs from
  18294. */
  18295. detachControl(element: Nullable<HTMLElement>): void;
  18296. /**
  18297. * Update the current camera state depending on the inputs that have been used this frame.
  18298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18299. */
  18300. checkInputs(): void;
  18301. /**
  18302. * Gets the class name of the current intput.
  18303. * @returns the class name
  18304. */
  18305. getClassName(): string;
  18306. /**
  18307. * Get the friendly name associated with the input class.
  18308. * @returns the input friendly name
  18309. */
  18310. getSimpleName(): string;
  18311. }
  18312. }
  18313. declare module BABYLON {
  18314. /**
  18315. * Default Inputs manager for the FreeCamera.
  18316. * It groups all the default supported inputs for ease of use.
  18317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18318. */
  18319. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18320. /**
  18321. * @hidden
  18322. */
  18323. _mouseInput: Nullable<FreeCameraMouseInput>;
  18324. /**
  18325. * Instantiates a new FreeCameraInputsManager.
  18326. * @param camera Defines the camera the inputs belong to
  18327. */
  18328. constructor(camera: FreeCamera);
  18329. /**
  18330. * Add keyboard input support to the input manager.
  18331. * @returns the current input manager
  18332. */
  18333. addKeyboard(): FreeCameraInputsManager;
  18334. /**
  18335. * Add mouse input support to the input manager.
  18336. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18337. * @returns the current input manager
  18338. */
  18339. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18340. /**
  18341. * Removes the mouse input support from the manager
  18342. * @returns the current input manager
  18343. */
  18344. removeMouse(): FreeCameraInputsManager;
  18345. /**
  18346. * Add touch input support to the input manager.
  18347. * @returns the current input manager
  18348. */
  18349. addTouch(): FreeCameraInputsManager;
  18350. /**
  18351. * Remove all attached input methods from a camera
  18352. */
  18353. clear(): void;
  18354. }
  18355. }
  18356. declare module BABYLON {
  18357. /**
  18358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18359. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18361. */
  18362. export class FreeCamera extends TargetCamera {
  18363. /**
  18364. * Define the collision ellipsoid of the camera.
  18365. * This is helpful to simulate a camera body like the player body around the camera
  18366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18367. */
  18368. ellipsoid: Vector3;
  18369. /**
  18370. * Define an offset for the position of the ellipsoid around the camera.
  18371. * This can be helpful to determine the center of the body near the gravity center of the body
  18372. * instead of its head.
  18373. */
  18374. ellipsoidOffset: Vector3;
  18375. /**
  18376. * Enable or disable collisions of the camera with the rest of the scene objects.
  18377. */
  18378. checkCollisions: boolean;
  18379. /**
  18380. * Enable or disable gravity on the camera.
  18381. */
  18382. applyGravity: boolean;
  18383. /**
  18384. * Define the input manager associated to the camera.
  18385. */
  18386. inputs: FreeCameraInputsManager;
  18387. /**
  18388. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18389. * Higher values reduce sensitivity.
  18390. */
  18391. get angularSensibility(): number;
  18392. /**
  18393. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18394. * Higher values reduce sensitivity.
  18395. */
  18396. set angularSensibility(value: number);
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18399. */
  18400. get keysUp(): number[];
  18401. set keysUp(value: number[]);
  18402. /**
  18403. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18404. */
  18405. get keysUpward(): number[];
  18406. set keysUpward(value: number[]);
  18407. /**
  18408. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18409. */
  18410. get keysDown(): number[];
  18411. set keysDown(value: number[]);
  18412. /**
  18413. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18414. */
  18415. get keysDownward(): number[];
  18416. set keysDownward(value: number[]);
  18417. /**
  18418. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18419. */
  18420. get keysLeft(): number[];
  18421. set keysLeft(value: number[]);
  18422. /**
  18423. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18424. */
  18425. get keysRight(): number[];
  18426. set keysRight(value: number[]);
  18427. /**
  18428. * Event raised when the camera collide with a mesh in the scene.
  18429. */
  18430. onCollide: (collidedMesh: AbstractMesh) => void;
  18431. private _collider;
  18432. private _needMoveForGravity;
  18433. private _oldPosition;
  18434. private _diffPosition;
  18435. private _newPosition;
  18436. /** @hidden */
  18437. _localDirection: Vector3;
  18438. /** @hidden */
  18439. _transformedDirection: Vector3;
  18440. /**
  18441. * Instantiates a Free Camera.
  18442. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18443. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18444. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18445. * @param name Define the name of the camera in the scene
  18446. * @param position Define the start position of the camera in the scene
  18447. * @param scene Define the scene the camera belongs to
  18448. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18449. */
  18450. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18451. /**
  18452. * Attached controls to the current camera.
  18453. * @param element Defines the element the controls should be listened from
  18454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18455. */
  18456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18457. /**
  18458. * Detach the current controls from the camera.
  18459. * The camera will stop reacting to inputs.
  18460. * @param element Defines the element to stop listening the inputs from
  18461. */
  18462. detachControl(element: HTMLElement): void;
  18463. private _collisionMask;
  18464. /**
  18465. * Define a collision mask to limit the list of object the camera can collide with
  18466. */
  18467. get collisionMask(): number;
  18468. set collisionMask(mask: number);
  18469. /** @hidden */
  18470. _collideWithWorld(displacement: Vector3): void;
  18471. private _onCollisionPositionChange;
  18472. /** @hidden */
  18473. _checkInputs(): void;
  18474. /** @hidden */
  18475. _decideIfNeedsToMove(): boolean;
  18476. /** @hidden */
  18477. _updatePosition(): void;
  18478. /**
  18479. * Destroy the camera and release the current resources hold by it.
  18480. */
  18481. dispose(): void;
  18482. /**
  18483. * Gets the current object class name.
  18484. * @return the class name
  18485. */
  18486. getClassName(): string;
  18487. }
  18488. }
  18489. declare module BABYLON {
  18490. /**
  18491. * Represents a gamepad control stick position
  18492. */
  18493. export class StickValues {
  18494. /**
  18495. * The x component of the control stick
  18496. */
  18497. x: number;
  18498. /**
  18499. * The y component of the control stick
  18500. */
  18501. y: number;
  18502. /**
  18503. * Initializes the gamepad x and y control stick values
  18504. * @param x The x component of the gamepad control stick value
  18505. * @param y The y component of the gamepad control stick value
  18506. */
  18507. constructor(
  18508. /**
  18509. * The x component of the control stick
  18510. */
  18511. x: number,
  18512. /**
  18513. * The y component of the control stick
  18514. */
  18515. y: number);
  18516. }
  18517. /**
  18518. * An interface which manages callbacks for gamepad button changes
  18519. */
  18520. export interface GamepadButtonChanges {
  18521. /**
  18522. * Called when a gamepad has been changed
  18523. */
  18524. changed: boolean;
  18525. /**
  18526. * Called when a gamepad press event has been triggered
  18527. */
  18528. pressChanged: boolean;
  18529. /**
  18530. * Called when a touch event has been triggered
  18531. */
  18532. touchChanged: boolean;
  18533. /**
  18534. * Called when a value has changed
  18535. */
  18536. valueChanged: boolean;
  18537. }
  18538. /**
  18539. * Represents a gamepad
  18540. */
  18541. export class Gamepad {
  18542. /**
  18543. * The id of the gamepad
  18544. */
  18545. id: string;
  18546. /**
  18547. * The index of the gamepad
  18548. */
  18549. index: number;
  18550. /**
  18551. * The browser gamepad
  18552. */
  18553. browserGamepad: any;
  18554. /**
  18555. * Specifies what type of gamepad this represents
  18556. */
  18557. type: number;
  18558. private _leftStick;
  18559. private _rightStick;
  18560. /** @hidden */
  18561. _isConnected: boolean;
  18562. private _leftStickAxisX;
  18563. private _leftStickAxisY;
  18564. private _rightStickAxisX;
  18565. private _rightStickAxisY;
  18566. /**
  18567. * Triggered when the left control stick has been changed
  18568. */
  18569. private _onleftstickchanged;
  18570. /**
  18571. * Triggered when the right control stick has been changed
  18572. */
  18573. private _onrightstickchanged;
  18574. /**
  18575. * Represents a gamepad controller
  18576. */
  18577. static GAMEPAD: number;
  18578. /**
  18579. * Represents a generic controller
  18580. */
  18581. static GENERIC: number;
  18582. /**
  18583. * Represents an XBox controller
  18584. */
  18585. static XBOX: number;
  18586. /**
  18587. * Represents a pose-enabled controller
  18588. */
  18589. static POSE_ENABLED: number;
  18590. /**
  18591. * Represents an Dual Shock controller
  18592. */
  18593. static DUALSHOCK: number;
  18594. /**
  18595. * Specifies whether the left control stick should be Y-inverted
  18596. */
  18597. protected _invertLeftStickY: boolean;
  18598. /**
  18599. * Specifies if the gamepad has been connected
  18600. */
  18601. get isConnected(): boolean;
  18602. /**
  18603. * Initializes the gamepad
  18604. * @param id The id of the gamepad
  18605. * @param index The index of the gamepad
  18606. * @param browserGamepad The browser gamepad
  18607. * @param leftStickX The x component of the left joystick
  18608. * @param leftStickY The y component of the left joystick
  18609. * @param rightStickX The x component of the right joystick
  18610. * @param rightStickY The y component of the right joystick
  18611. */
  18612. constructor(
  18613. /**
  18614. * The id of the gamepad
  18615. */
  18616. id: string,
  18617. /**
  18618. * The index of the gamepad
  18619. */
  18620. index: number,
  18621. /**
  18622. * The browser gamepad
  18623. */
  18624. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18625. /**
  18626. * Callback triggered when the left joystick has changed
  18627. * @param callback
  18628. */
  18629. onleftstickchanged(callback: (values: StickValues) => void): void;
  18630. /**
  18631. * Callback triggered when the right joystick has changed
  18632. * @param callback
  18633. */
  18634. onrightstickchanged(callback: (values: StickValues) => void): void;
  18635. /**
  18636. * Gets the left joystick
  18637. */
  18638. get leftStick(): StickValues;
  18639. /**
  18640. * Sets the left joystick values
  18641. */
  18642. set leftStick(newValues: StickValues);
  18643. /**
  18644. * Gets the right joystick
  18645. */
  18646. get rightStick(): StickValues;
  18647. /**
  18648. * Sets the right joystick value
  18649. */
  18650. set rightStick(newValues: StickValues);
  18651. /**
  18652. * Updates the gamepad joystick positions
  18653. */
  18654. update(): void;
  18655. /**
  18656. * Disposes the gamepad
  18657. */
  18658. dispose(): void;
  18659. }
  18660. /**
  18661. * Represents a generic gamepad
  18662. */
  18663. export class GenericPad extends Gamepad {
  18664. private _buttons;
  18665. private _onbuttondown;
  18666. private _onbuttonup;
  18667. /**
  18668. * Observable triggered when a button has been pressed
  18669. */
  18670. onButtonDownObservable: Observable<number>;
  18671. /**
  18672. * Observable triggered when a button has been released
  18673. */
  18674. onButtonUpObservable: Observable<number>;
  18675. /**
  18676. * Callback triggered when a button has been pressed
  18677. * @param callback Called when a button has been pressed
  18678. */
  18679. onbuttondown(callback: (buttonPressed: number) => void): void;
  18680. /**
  18681. * Callback triggered when a button has been released
  18682. * @param callback Called when a button has been released
  18683. */
  18684. onbuttonup(callback: (buttonReleased: number) => void): void;
  18685. /**
  18686. * Initializes the generic gamepad
  18687. * @param id The id of the generic gamepad
  18688. * @param index The index of the generic gamepad
  18689. * @param browserGamepad The browser gamepad
  18690. */
  18691. constructor(id: string, index: number, browserGamepad: any);
  18692. private _setButtonValue;
  18693. /**
  18694. * Updates the generic gamepad
  18695. */
  18696. update(): void;
  18697. /**
  18698. * Disposes the generic gamepad
  18699. */
  18700. dispose(): void;
  18701. }
  18702. }
  18703. declare module BABYLON {
  18704. /**
  18705. * Defines the types of pose enabled controllers that are supported
  18706. */
  18707. export enum PoseEnabledControllerType {
  18708. /**
  18709. * HTC Vive
  18710. */
  18711. VIVE = 0,
  18712. /**
  18713. * Oculus Rift
  18714. */
  18715. OCULUS = 1,
  18716. /**
  18717. * Windows mixed reality
  18718. */
  18719. WINDOWS = 2,
  18720. /**
  18721. * Samsung gear VR
  18722. */
  18723. GEAR_VR = 3,
  18724. /**
  18725. * Google Daydream
  18726. */
  18727. DAYDREAM = 4,
  18728. /**
  18729. * Generic
  18730. */
  18731. GENERIC = 5
  18732. }
  18733. /**
  18734. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18735. */
  18736. export interface MutableGamepadButton {
  18737. /**
  18738. * Value of the button/trigger
  18739. */
  18740. value: number;
  18741. /**
  18742. * If the button/trigger is currently touched
  18743. */
  18744. touched: boolean;
  18745. /**
  18746. * If the button/trigger is currently pressed
  18747. */
  18748. pressed: boolean;
  18749. }
  18750. /**
  18751. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18752. * @hidden
  18753. */
  18754. export interface ExtendedGamepadButton extends GamepadButton {
  18755. /**
  18756. * If the button/trigger is currently pressed
  18757. */
  18758. readonly pressed: boolean;
  18759. /**
  18760. * If the button/trigger is currently touched
  18761. */
  18762. readonly touched: boolean;
  18763. /**
  18764. * Value of the button/trigger
  18765. */
  18766. readonly value: number;
  18767. }
  18768. /** @hidden */
  18769. export interface _GamePadFactory {
  18770. /**
  18771. * Returns whether or not the current gamepad can be created for this type of controller.
  18772. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18773. * @returns true if it can be created, otherwise false
  18774. */
  18775. canCreate(gamepadInfo: any): boolean;
  18776. /**
  18777. * Creates a new instance of the Gamepad.
  18778. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18779. * @returns the new gamepad instance
  18780. */
  18781. create(gamepadInfo: any): Gamepad;
  18782. }
  18783. /**
  18784. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18785. */
  18786. export class PoseEnabledControllerHelper {
  18787. /** @hidden */
  18788. static _ControllerFactories: _GamePadFactory[];
  18789. /** @hidden */
  18790. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18791. /**
  18792. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18793. * @param vrGamepad the gamepad to initialized
  18794. * @returns a vr controller of the type the gamepad identified as
  18795. */
  18796. static InitiateController(vrGamepad: any): Gamepad;
  18797. }
  18798. /**
  18799. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18800. */
  18801. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18802. /**
  18803. * If the controller is used in a webXR session
  18804. */
  18805. isXR: boolean;
  18806. private _deviceRoomPosition;
  18807. private _deviceRoomRotationQuaternion;
  18808. /**
  18809. * The device position in babylon space
  18810. */
  18811. devicePosition: Vector3;
  18812. /**
  18813. * The device rotation in babylon space
  18814. */
  18815. deviceRotationQuaternion: Quaternion;
  18816. /**
  18817. * The scale factor of the device in babylon space
  18818. */
  18819. deviceScaleFactor: number;
  18820. /**
  18821. * (Likely devicePosition should be used instead) The device position in its room space
  18822. */
  18823. position: Vector3;
  18824. /**
  18825. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18826. */
  18827. rotationQuaternion: Quaternion;
  18828. /**
  18829. * The type of controller (Eg. Windows mixed reality)
  18830. */
  18831. controllerType: PoseEnabledControllerType;
  18832. protected _calculatedPosition: Vector3;
  18833. private _calculatedRotation;
  18834. /**
  18835. * The raw pose from the device
  18836. */
  18837. rawPose: DevicePose;
  18838. private _trackPosition;
  18839. private _maxRotationDistFromHeadset;
  18840. private _draggedRoomRotation;
  18841. /**
  18842. * @hidden
  18843. */
  18844. _disableTrackPosition(fixedPosition: Vector3): void;
  18845. /**
  18846. * Internal, the mesh attached to the controller
  18847. * @hidden
  18848. */
  18849. _mesh: Nullable<AbstractMesh>;
  18850. private _poseControlledCamera;
  18851. private _leftHandSystemQuaternion;
  18852. /**
  18853. * Internal, matrix used to convert room space to babylon space
  18854. * @hidden
  18855. */
  18856. _deviceToWorld: Matrix;
  18857. /**
  18858. * Node to be used when casting a ray from the controller
  18859. * @hidden
  18860. */
  18861. _pointingPoseNode: Nullable<TransformNode>;
  18862. /**
  18863. * Name of the child mesh that can be used to cast a ray from the controller
  18864. */
  18865. static readonly POINTING_POSE: string;
  18866. /**
  18867. * Creates a new PoseEnabledController from a gamepad
  18868. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18869. */
  18870. constructor(browserGamepad: any);
  18871. private _workingMatrix;
  18872. /**
  18873. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18874. */
  18875. update(): void;
  18876. /**
  18877. * Updates only the pose device and mesh without doing any button event checking
  18878. */
  18879. protected _updatePoseAndMesh(): void;
  18880. /**
  18881. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18882. * @param poseData raw pose fromthe device
  18883. */
  18884. updateFromDevice(poseData: DevicePose): void;
  18885. /**
  18886. * @hidden
  18887. */
  18888. _meshAttachedObservable: Observable<AbstractMesh>;
  18889. /**
  18890. * Attaches a mesh to the controller
  18891. * @param mesh the mesh to be attached
  18892. */
  18893. attachToMesh(mesh: AbstractMesh): void;
  18894. /**
  18895. * Attaches the controllers mesh to a camera
  18896. * @param camera the camera the mesh should be attached to
  18897. */
  18898. attachToPoseControlledCamera(camera: TargetCamera): void;
  18899. /**
  18900. * Disposes of the controller
  18901. */
  18902. dispose(): void;
  18903. /**
  18904. * The mesh that is attached to the controller
  18905. */
  18906. get mesh(): Nullable<AbstractMesh>;
  18907. /**
  18908. * Gets the ray of the controller in the direction the controller is pointing
  18909. * @param length the length the resulting ray should be
  18910. * @returns a ray in the direction the controller is pointing
  18911. */
  18912. getForwardRay(length?: number): Ray;
  18913. }
  18914. }
  18915. declare module BABYLON {
  18916. /**
  18917. * Defines the WebVRController object that represents controllers tracked in 3D space
  18918. */
  18919. export abstract class WebVRController extends PoseEnabledController {
  18920. /**
  18921. * Internal, the default controller model for the controller
  18922. */
  18923. protected _defaultModel: Nullable<AbstractMesh>;
  18924. /**
  18925. * Fired when the trigger state has changed
  18926. */
  18927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18928. /**
  18929. * Fired when the main button state has changed
  18930. */
  18931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18932. /**
  18933. * Fired when the secondary button state has changed
  18934. */
  18935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18936. /**
  18937. * Fired when the pad state has changed
  18938. */
  18939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18940. /**
  18941. * Fired when controllers stick values have changed
  18942. */
  18943. onPadValuesChangedObservable: Observable<StickValues>;
  18944. /**
  18945. * Array of button availible on the controller
  18946. */
  18947. protected _buttons: Array<MutableGamepadButton>;
  18948. private _onButtonStateChange;
  18949. /**
  18950. * Fired when a controller button's state has changed
  18951. * @param callback the callback containing the button that was modified
  18952. */
  18953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18954. /**
  18955. * X and Y axis corresponding to the controllers joystick
  18956. */
  18957. pad: StickValues;
  18958. /**
  18959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18960. */
  18961. hand: string;
  18962. /**
  18963. * The default controller model for the controller
  18964. */
  18965. get defaultModel(): Nullable<AbstractMesh>;
  18966. /**
  18967. * Creates a new WebVRController from a gamepad
  18968. * @param vrGamepad the gamepad that the WebVRController should be created from
  18969. */
  18970. constructor(vrGamepad: any);
  18971. /**
  18972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18973. */
  18974. update(): void;
  18975. /**
  18976. * Function to be called when a button is modified
  18977. */
  18978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18979. /**
  18980. * Loads a mesh and attaches it to the controller
  18981. * @param scene the scene the mesh should be added to
  18982. * @param meshLoaded callback for when the mesh has been loaded
  18983. */
  18984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18985. private _setButtonValue;
  18986. private _changes;
  18987. private _checkChanges;
  18988. /**
  18989. * Disposes of th webVRCOntroller
  18990. */
  18991. dispose(): void;
  18992. }
  18993. }
  18994. declare module BABYLON {
  18995. /**
  18996. * The HemisphericLight simulates the ambient environment light,
  18997. * so the passed direction is the light reflection direction, not the incoming direction.
  18998. */
  18999. export class HemisphericLight extends Light {
  19000. /**
  19001. * The groundColor is the light in the opposite direction to the one specified during creation.
  19002. * 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.
  19003. */
  19004. groundColor: Color3;
  19005. /**
  19006. * The light reflection direction, not the incoming direction.
  19007. */
  19008. direction: Vector3;
  19009. /**
  19010. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19011. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19012. * The HemisphericLight can't cast shadows.
  19013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19014. * @param name The friendly name of the light
  19015. * @param direction The direction of the light reflection
  19016. * @param scene The scene the light belongs to
  19017. */
  19018. constructor(name: string, direction: Vector3, scene: Scene);
  19019. protected _buildUniformLayout(): void;
  19020. /**
  19021. * Returns the string "HemisphericLight".
  19022. * @return The class name
  19023. */
  19024. getClassName(): string;
  19025. /**
  19026. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19027. * Returns the updated direction.
  19028. * @param target The target the direction should point to
  19029. * @return The computed direction
  19030. */
  19031. setDirectionToTarget(target: Vector3): Vector3;
  19032. /**
  19033. * Returns the shadow generator associated to the light.
  19034. * @returns Always null for hemispheric lights because it does not support shadows.
  19035. */
  19036. getShadowGenerator(): Nullable<IShadowGenerator>;
  19037. /**
  19038. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19039. * @param effect The effect to update
  19040. * @param lightIndex The index of the light in the effect to update
  19041. * @returns The hemispheric light
  19042. */
  19043. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19044. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19045. /**
  19046. * Computes the world matrix of the node
  19047. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19048. * @param useWasUpdatedFlag defines a reserved property
  19049. * @returns the world matrix
  19050. */
  19051. computeWorldMatrix(): Matrix;
  19052. /**
  19053. * Returns the integer 3.
  19054. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19055. */
  19056. getTypeID(): number;
  19057. /**
  19058. * Prepares the list of defines specific to the light type.
  19059. * @param defines the list of defines
  19060. * @param lightIndex defines the index of the light for the effect
  19061. */
  19062. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19063. }
  19064. }
  19065. declare module BABYLON {
  19066. /** @hidden */
  19067. export var vrMultiviewToSingleviewPixelShader: {
  19068. name: string;
  19069. shader: string;
  19070. };
  19071. }
  19072. declare module BABYLON {
  19073. /**
  19074. * Renders to multiple views with a single draw call
  19075. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19076. */
  19077. export class MultiviewRenderTarget extends RenderTargetTexture {
  19078. /**
  19079. * Creates a multiview render target
  19080. * @param scene scene used with the render target
  19081. * @param size the size of the render target (used for each view)
  19082. */
  19083. constructor(scene: Scene, size?: number | {
  19084. width: number;
  19085. height: number;
  19086. } | {
  19087. ratio: number;
  19088. });
  19089. /**
  19090. * @hidden
  19091. * @param faceIndex the face index, if its a cube texture
  19092. */
  19093. _bindFrameBuffer(faceIndex?: number): void;
  19094. /**
  19095. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19096. * @returns the view count
  19097. */
  19098. getViewCount(): number;
  19099. }
  19100. }
  19101. declare module BABYLON {
  19102. /**
  19103. * Represents a camera frustum
  19104. */
  19105. export class Frustum {
  19106. /**
  19107. * Gets the planes representing the frustum
  19108. * @param transform matrix to be applied to the returned planes
  19109. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19110. */
  19111. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19112. /**
  19113. * Gets the near frustum plane transformed by the transform matrix
  19114. * @param transform transformation matrix to be applied to the resulting frustum plane
  19115. * @param frustumPlane the resuling frustum plane
  19116. */
  19117. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19118. /**
  19119. * Gets the far frustum plane transformed by the transform matrix
  19120. * @param transform transformation matrix to be applied to the resulting frustum plane
  19121. * @param frustumPlane the resuling frustum plane
  19122. */
  19123. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19124. /**
  19125. * Gets the left frustum plane transformed by the transform matrix
  19126. * @param transform transformation matrix to be applied to the resulting frustum plane
  19127. * @param frustumPlane the resuling frustum plane
  19128. */
  19129. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19130. /**
  19131. * Gets the right frustum plane transformed by the transform matrix
  19132. * @param transform transformation matrix to be applied to the resulting frustum plane
  19133. * @param frustumPlane the resuling frustum plane
  19134. */
  19135. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19136. /**
  19137. * Gets the top frustum plane transformed by the transform matrix
  19138. * @param transform transformation matrix to be applied to the resulting frustum plane
  19139. * @param frustumPlane the resuling frustum plane
  19140. */
  19141. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19142. /**
  19143. * Gets the bottom frustum plane transformed by the transform matrix
  19144. * @param transform transformation matrix to be applied to the resulting frustum plane
  19145. * @param frustumPlane the resuling frustum plane
  19146. */
  19147. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19148. /**
  19149. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19150. * @param transform transformation matrix to be applied to the resulting frustum planes
  19151. * @param frustumPlanes the resuling frustum planes
  19152. */
  19153. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19154. }
  19155. }
  19156. declare module BABYLON {
  19157. interface Engine {
  19158. /**
  19159. * Creates a new multiview render target
  19160. * @param width defines the width of the texture
  19161. * @param height defines the height of the texture
  19162. * @returns the created multiview texture
  19163. */
  19164. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19165. /**
  19166. * Binds a multiview framebuffer to be drawn to
  19167. * @param multiviewTexture texture to bind
  19168. */
  19169. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19170. }
  19171. interface Camera {
  19172. /**
  19173. * @hidden
  19174. * 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)
  19175. */
  19176. _useMultiviewToSingleView: boolean;
  19177. /**
  19178. * @hidden
  19179. * 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)
  19180. */
  19181. _multiviewTexture: Nullable<RenderTargetTexture>;
  19182. /**
  19183. * @hidden
  19184. * ensures the multiview texture of the camera exists and has the specified width/height
  19185. * @param width height to set on the multiview texture
  19186. * @param height width to set on the multiview texture
  19187. */
  19188. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19189. }
  19190. interface Scene {
  19191. /** @hidden */
  19192. _transformMatrixR: Matrix;
  19193. /** @hidden */
  19194. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19195. /** @hidden */
  19196. _createMultiviewUbo(): void;
  19197. /** @hidden */
  19198. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19199. /** @hidden */
  19200. _renderMultiviewToSingleView(camera: Camera): void;
  19201. }
  19202. }
  19203. declare module BABYLON {
  19204. /**
  19205. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19206. * This will not be used for webXR as it supports displaying texture arrays directly
  19207. */
  19208. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19209. /**
  19210. * Initializes a VRMultiviewToSingleview
  19211. * @param name name of the post process
  19212. * @param camera camera to be applied to
  19213. * @param scaleFactor scaling factor to the size of the output texture
  19214. */
  19215. constructor(name: string, camera: Camera, scaleFactor: number);
  19216. }
  19217. }
  19218. declare module BABYLON {
  19219. /**
  19220. * Interface used to define additional presentation attributes
  19221. */
  19222. export interface IVRPresentationAttributes {
  19223. /**
  19224. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19225. */
  19226. highRefreshRate: boolean;
  19227. /**
  19228. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19229. */
  19230. foveationLevel: number;
  19231. }
  19232. interface Engine {
  19233. /** @hidden */
  19234. _vrDisplay: any;
  19235. /** @hidden */
  19236. _vrSupported: boolean;
  19237. /** @hidden */
  19238. _oldSize: Size;
  19239. /** @hidden */
  19240. _oldHardwareScaleFactor: number;
  19241. /** @hidden */
  19242. _vrExclusivePointerMode: boolean;
  19243. /** @hidden */
  19244. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19245. /** @hidden */
  19246. _onVRDisplayPointerRestricted: () => void;
  19247. /** @hidden */
  19248. _onVRDisplayPointerUnrestricted: () => void;
  19249. /** @hidden */
  19250. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19251. /** @hidden */
  19252. _onVrDisplayDisconnect: Nullable<() => void>;
  19253. /** @hidden */
  19254. _onVrDisplayPresentChange: Nullable<() => void>;
  19255. /**
  19256. * Observable signaled when VR display mode changes
  19257. */
  19258. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19259. /**
  19260. * Observable signaled when VR request present is complete
  19261. */
  19262. onVRRequestPresentComplete: Observable<boolean>;
  19263. /**
  19264. * Observable signaled when VR request present starts
  19265. */
  19266. onVRRequestPresentStart: Observable<Engine>;
  19267. /**
  19268. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19269. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19270. */
  19271. isInVRExclusivePointerMode: boolean;
  19272. /**
  19273. * Gets a boolean indicating if a webVR device was detected
  19274. * @returns true if a webVR device was detected
  19275. */
  19276. isVRDevicePresent(): boolean;
  19277. /**
  19278. * Gets the current webVR device
  19279. * @returns the current webVR device (or null)
  19280. */
  19281. getVRDevice(): any;
  19282. /**
  19283. * Initializes a webVR display and starts listening to display change events
  19284. * The onVRDisplayChangedObservable will be notified upon these changes
  19285. * @returns A promise containing a VRDisplay and if vr is supported
  19286. */
  19287. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19288. /** @hidden */
  19289. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19290. /**
  19291. * Gets or sets the presentation attributes used to configure VR rendering
  19292. */
  19293. vrPresentationAttributes?: IVRPresentationAttributes;
  19294. /**
  19295. * Call this function to switch to webVR mode
  19296. * Will do nothing if webVR is not supported or if there is no webVR device
  19297. * @param options the webvr options provided to the camera. mainly used for multiview
  19298. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19299. */
  19300. enableVR(options: WebVROptions): void;
  19301. /** @hidden */
  19302. _onVRFullScreenTriggered(): void;
  19303. }
  19304. }
  19305. declare module BABYLON {
  19306. /**
  19307. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19308. * IMPORTANT!! The data is right-hand data.
  19309. * @export
  19310. * @interface DevicePose
  19311. */
  19312. export interface DevicePose {
  19313. /**
  19314. * The position of the device, values in array are [x,y,z].
  19315. */
  19316. readonly position: Nullable<Float32Array>;
  19317. /**
  19318. * The linearVelocity of the device, values in array are [x,y,z].
  19319. */
  19320. readonly linearVelocity: Nullable<Float32Array>;
  19321. /**
  19322. * The linearAcceleration of the device, values in array are [x,y,z].
  19323. */
  19324. readonly linearAcceleration: Nullable<Float32Array>;
  19325. /**
  19326. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19327. */
  19328. readonly orientation: Nullable<Float32Array>;
  19329. /**
  19330. * The angularVelocity of the device, values in array are [x,y,z].
  19331. */
  19332. readonly angularVelocity: Nullable<Float32Array>;
  19333. /**
  19334. * The angularAcceleration of the device, values in array are [x,y,z].
  19335. */
  19336. readonly angularAcceleration: Nullable<Float32Array>;
  19337. }
  19338. /**
  19339. * Interface representing a pose controlled object in Babylon.
  19340. * A pose controlled object has both regular pose values as well as pose values
  19341. * from an external device such as a VR head mounted display
  19342. */
  19343. export interface PoseControlled {
  19344. /**
  19345. * The position of the object in babylon space.
  19346. */
  19347. position: Vector3;
  19348. /**
  19349. * The rotation quaternion of the object in babylon space.
  19350. */
  19351. rotationQuaternion: Quaternion;
  19352. /**
  19353. * The position of the device in babylon space.
  19354. */
  19355. devicePosition?: Vector3;
  19356. /**
  19357. * The rotation quaternion of the device in babylon space.
  19358. */
  19359. deviceRotationQuaternion: Quaternion;
  19360. /**
  19361. * The raw pose coming from the device.
  19362. */
  19363. rawPose: Nullable<DevicePose>;
  19364. /**
  19365. * The scale of the device to be used when translating from device space to babylon space.
  19366. */
  19367. deviceScaleFactor: number;
  19368. /**
  19369. * Updates the poseControlled values based on the input device pose.
  19370. * @param poseData the pose data to update the object with
  19371. */
  19372. updateFromDevice(poseData: DevicePose): void;
  19373. }
  19374. /**
  19375. * Set of options to customize the webVRCamera
  19376. */
  19377. export interface WebVROptions {
  19378. /**
  19379. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19380. */
  19381. trackPosition?: boolean;
  19382. /**
  19383. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19384. */
  19385. positionScale?: number;
  19386. /**
  19387. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19388. */
  19389. displayName?: string;
  19390. /**
  19391. * Should the native controller meshes be initialized. (default: true)
  19392. */
  19393. controllerMeshes?: boolean;
  19394. /**
  19395. * Creating a default HemiLight only on controllers. (default: true)
  19396. */
  19397. defaultLightingOnControllers?: boolean;
  19398. /**
  19399. * If you don't want to use the default VR button of the helper. (default: false)
  19400. */
  19401. useCustomVRButton?: boolean;
  19402. /**
  19403. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19404. */
  19405. customVRButton?: HTMLButtonElement;
  19406. /**
  19407. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19408. */
  19409. rayLength?: number;
  19410. /**
  19411. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19412. */
  19413. defaultHeight?: number;
  19414. /**
  19415. * If multiview should be used if availible (default: false)
  19416. */
  19417. useMultiview?: boolean;
  19418. }
  19419. /**
  19420. * This represents a WebVR camera.
  19421. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19422. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19423. */
  19424. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19425. private webVROptions;
  19426. /**
  19427. * @hidden
  19428. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19429. */
  19430. _vrDevice: any;
  19431. /**
  19432. * The rawPose of the vrDevice.
  19433. */
  19434. rawPose: Nullable<DevicePose>;
  19435. private _onVREnabled;
  19436. private _specsVersion;
  19437. private _attached;
  19438. private _frameData;
  19439. protected _descendants: Array<Node>;
  19440. private _deviceRoomPosition;
  19441. /** @hidden */
  19442. _deviceRoomRotationQuaternion: Quaternion;
  19443. private _standingMatrix;
  19444. /**
  19445. * Represents device position in babylon space.
  19446. */
  19447. devicePosition: Vector3;
  19448. /**
  19449. * Represents device rotation in babylon space.
  19450. */
  19451. deviceRotationQuaternion: Quaternion;
  19452. /**
  19453. * The scale of the device to be used when translating from device space to babylon space.
  19454. */
  19455. deviceScaleFactor: number;
  19456. private _deviceToWorld;
  19457. private _worldToDevice;
  19458. /**
  19459. * References to the webVR controllers for the vrDevice.
  19460. */
  19461. controllers: Array<WebVRController>;
  19462. /**
  19463. * Emits an event when a controller is attached.
  19464. */
  19465. onControllersAttachedObservable: Observable<WebVRController[]>;
  19466. /**
  19467. * Emits an event when a controller's mesh has been loaded;
  19468. */
  19469. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19470. /**
  19471. * Emits an event when the HMD's pose has been updated.
  19472. */
  19473. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19474. private _poseSet;
  19475. /**
  19476. * If the rig cameras be used as parent instead of this camera.
  19477. */
  19478. rigParenting: boolean;
  19479. private _lightOnControllers;
  19480. private _defaultHeight?;
  19481. /**
  19482. * Instantiates a WebVRFreeCamera.
  19483. * @param name The name of the WebVRFreeCamera
  19484. * @param position The starting anchor position for the camera
  19485. * @param scene The scene the camera belongs to
  19486. * @param webVROptions a set of customizable options for the webVRCamera
  19487. */
  19488. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19489. /**
  19490. * Gets the device distance from the ground in meters.
  19491. * @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.
  19492. */
  19493. deviceDistanceToRoomGround(): number;
  19494. /**
  19495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19496. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19497. */
  19498. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19499. /**
  19500. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19501. * @returns A promise with a boolean set to if the standing matrix is supported.
  19502. */
  19503. useStandingMatrixAsync(): Promise<boolean>;
  19504. /**
  19505. * Disposes the camera
  19506. */
  19507. dispose(): void;
  19508. /**
  19509. * Gets a vrController by name.
  19510. * @param name The name of the controller to retreive
  19511. * @returns the controller matching the name specified or null if not found
  19512. */
  19513. getControllerByName(name: string): Nullable<WebVRController>;
  19514. private _leftController;
  19515. /**
  19516. * The controller corresponding to the users left hand.
  19517. */
  19518. get leftController(): Nullable<WebVRController>;
  19519. private _rightController;
  19520. /**
  19521. * The controller corresponding to the users right hand.
  19522. */
  19523. get rightController(): Nullable<WebVRController>;
  19524. /**
  19525. * Casts a ray forward from the vrCamera's gaze.
  19526. * @param length Length of the ray (default: 100)
  19527. * @returns the ray corresponding to the gaze
  19528. */
  19529. getForwardRay(length?: number): Ray;
  19530. /**
  19531. * @hidden
  19532. * Updates the camera based on device's frame data
  19533. */
  19534. _checkInputs(): void;
  19535. /**
  19536. * Updates the poseControlled values based on the input device pose.
  19537. * @param poseData Pose coming from the device
  19538. */
  19539. updateFromDevice(poseData: DevicePose): void;
  19540. private _htmlElementAttached;
  19541. private _detachIfAttached;
  19542. /**
  19543. * WebVR's attach control will start broadcasting frames to the device.
  19544. * Note that in certain browsers (chrome for example) this function must be called
  19545. * within a user-interaction callback. Example:
  19546. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19547. *
  19548. * @param element html element to attach the vrDevice to
  19549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19550. */
  19551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19552. /**
  19553. * Detaches the camera from the html element and disables VR
  19554. *
  19555. * @param element html element to detach from
  19556. */
  19557. detachControl(element: HTMLElement): void;
  19558. /**
  19559. * @returns the name of this class
  19560. */
  19561. getClassName(): string;
  19562. /**
  19563. * Calls resetPose on the vrDisplay
  19564. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19565. */
  19566. resetToCurrentRotation(): void;
  19567. /**
  19568. * @hidden
  19569. * Updates the rig cameras (left and right eye)
  19570. */
  19571. _updateRigCameras(): void;
  19572. private _workingVector;
  19573. private _oneVector;
  19574. private _workingMatrix;
  19575. private updateCacheCalled;
  19576. private _correctPositionIfNotTrackPosition;
  19577. /**
  19578. * @hidden
  19579. * Updates the cached values of the camera
  19580. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19581. */
  19582. _updateCache(ignoreParentClass?: boolean): void;
  19583. /**
  19584. * @hidden
  19585. * Get current device position in babylon world
  19586. */
  19587. _computeDevicePosition(): void;
  19588. /**
  19589. * Updates the current device position and rotation in the babylon world
  19590. */
  19591. update(): void;
  19592. /**
  19593. * @hidden
  19594. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19595. * @returns an identity matrix
  19596. */
  19597. _getViewMatrix(): Matrix;
  19598. private _tmpMatrix;
  19599. /**
  19600. * This function is called by the two RIG cameras.
  19601. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19602. * @hidden
  19603. */
  19604. _getWebVRViewMatrix(): Matrix;
  19605. /** @hidden */
  19606. _getWebVRProjectionMatrix(): Matrix;
  19607. private _onGamepadConnectedObserver;
  19608. private _onGamepadDisconnectedObserver;
  19609. private _updateCacheWhenTrackingDisabledObserver;
  19610. /**
  19611. * Initializes the controllers and their meshes
  19612. */
  19613. initControllers(): void;
  19614. }
  19615. }
  19616. declare module BABYLON {
  19617. /**
  19618. * Size options for a post process
  19619. */
  19620. export type PostProcessOptions = {
  19621. width: number;
  19622. height: number;
  19623. };
  19624. /**
  19625. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19626. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19627. */
  19628. export class PostProcess {
  19629. /** Name of the PostProcess. */
  19630. name: string;
  19631. /**
  19632. * Gets or sets the unique id of the post process
  19633. */
  19634. uniqueId: number;
  19635. /**
  19636. * Width of the texture to apply the post process on
  19637. */
  19638. width: number;
  19639. /**
  19640. * Height of the texture to apply the post process on
  19641. */
  19642. height: number;
  19643. /**
  19644. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19645. * @hidden
  19646. */
  19647. _outputTexture: Nullable<InternalTexture>;
  19648. /**
  19649. * Sampling mode used by the shader
  19650. * See https://doc.babylonjs.com/classes/3.1/texture
  19651. */
  19652. renderTargetSamplingMode: number;
  19653. /**
  19654. * Clear color to use when screen clearing
  19655. */
  19656. clearColor: Color4;
  19657. /**
  19658. * If the buffer needs to be cleared before applying the post process. (default: true)
  19659. * Should be set to false if shader will overwrite all previous pixels.
  19660. */
  19661. autoClear: boolean;
  19662. /**
  19663. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19664. */
  19665. alphaMode: number;
  19666. /**
  19667. * Sets the setAlphaBlendConstants of the babylon engine
  19668. */
  19669. alphaConstants: Color4;
  19670. /**
  19671. * Animations to be used for the post processing
  19672. */
  19673. animations: Animation[];
  19674. /**
  19675. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19676. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19677. */
  19678. enablePixelPerfectMode: boolean;
  19679. /**
  19680. * Force the postprocess to be applied without taking in account viewport
  19681. */
  19682. forceFullscreenViewport: boolean;
  19683. /**
  19684. * List of inspectable custom properties (used by the Inspector)
  19685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19686. */
  19687. inspectableCustomProperties: IInspectable[];
  19688. /**
  19689. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19690. *
  19691. * | Value | Type | Description |
  19692. * | ----- | ----------------------------------- | ----------- |
  19693. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19694. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19695. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19696. *
  19697. */
  19698. scaleMode: number;
  19699. /**
  19700. * Force textures to be a power of two (default: false)
  19701. */
  19702. alwaysForcePOT: boolean;
  19703. private _samples;
  19704. /**
  19705. * Number of sample textures (default: 1)
  19706. */
  19707. get samples(): number;
  19708. set samples(n: number);
  19709. /**
  19710. * Modify the scale of the post process to be the same as the viewport (default: false)
  19711. */
  19712. adaptScaleToCurrentViewport: boolean;
  19713. private _camera;
  19714. private _scene;
  19715. private _engine;
  19716. private _options;
  19717. private _reusable;
  19718. private _textureType;
  19719. private _textureFormat;
  19720. /**
  19721. * Smart array of input and output textures for the post process.
  19722. * @hidden
  19723. */
  19724. _textures: SmartArray<InternalTexture>;
  19725. /**
  19726. * The index in _textures that corresponds to the output texture.
  19727. * @hidden
  19728. */
  19729. _currentRenderTextureInd: number;
  19730. private _effect;
  19731. private _samplers;
  19732. private _fragmentUrl;
  19733. private _vertexUrl;
  19734. private _parameters;
  19735. private _scaleRatio;
  19736. protected _indexParameters: any;
  19737. private _shareOutputWithPostProcess;
  19738. private _texelSize;
  19739. private _forcedOutputTexture;
  19740. /**
  19741. * Returns the fragment url or shader name used in the post process.
  19742. * @returns the fragment url or name in the shader store.
  19743. */
  19744. getEffectName(): string;
  19745. /**
  19746. * An event triggered when the postprocess is activated.
  19747. */
  19748. onActivateObservable: Observable<Camera>;
  19749. private _onActivateObserver;
  19750. /**
  19751. * A function that is added to the onActivateObservable
  19752. */
  19753. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19754. /**
  19755. * An event triggered when the postprocess changes its size.
  19756. */
  19757. onSizeChangedObservable: Observable<PostProcess>;
  19758. private _onSizeChangedObserver;
  19759. /**
  19760. * A function that is added to the onSizeChangedObservable
  19761. */
  19762. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19763. /**
  19764. * An event triggered when the postprocess applies its effect.
  19765. */
  19766. onApplyObservable: Observable<Effect>;
  19767. private _onApplyObserver;
  19768. /**
  19769. * A function that is added to the onApplyObservable
  19770. */
  19771. set onApply(callback: (effect: Effect) => void);
  19772. /**
  19773. * An event triggered before rendering the postprocess
  19774. */
  19775. onBeforeRenderObservable: Observable<Effect>;
  19776. private _onBeforeRenderObserver;
  19777. /**
  19778. * A function that is added to the onBeforeRenderObservable
  19779. */
  19780. set onBeforeRender(callback: (effect: Effect) => void);
  19781. /**
  19782. * An event triggered after rendering the postprocess
  19783. */
  19784. onAfterRenderObservable: Observable<Effect>;
  19785. private _onAfterRenderObserver;
  19786. /**
  19787. * A function that is added to the onAfterRenderObservable
  19788. */
  19789. set onAfterRender(callback: (efect: Effect) => void);
  19790. /**
  19791. * 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
  19792. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19793. */
  19794. get inputTexture(): InternalTexture;
  19795. set inputTexture(value: InternalTexture);
  19796. /**
  19797. * Gets the camera which post process is applied to.
  19798. * @returns The camera the post process is applied to.
  19799. */
  19800. getCamera(): Camera;
  19801. /**
  19802. * Gets the texel size of the postprocess.
  19803. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19804. */
  19805. get texelSize(): Vector2;
  19806. /**
  19807. * Creates a new instance PostProcess
  19808. * @param name The name of the PostProcess.
  19809. * @param fragmentUrl The url of the fragment shader to be used.
  19810. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19811. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19812. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19813. * @param camera The camera to apply the render pass to.
  19814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19815. * @param engine The engine which the post process will be applied. (default: current engine)
  19816. * @param reusable If the post process can be reused on the same frame. (default: false)
  19817. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19818. * @param textureType Type of textures used when performing the post process. (default: 0)
  19819. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19820. * @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
  19821. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19822. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19823. */
  19824. constructor(
  19825. /** Name of the PostProcess. */
  19826. 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);
  19827. /**
  19828. * Gets a string idenfifying the name of the class
  19829. * @returns "PostProcess" string
  19830. */
  19831. getClassName(): string;
  19832. /**
  19833. * Gets the engine which this post process belongs to.
  19834. * @returns The engine the post process was enabled with.
  19835. */
  19836. getEngine(): Engine;
  19837. /**
  19838. * The effect that is created when initializing the post process.
  19839. * @returns The created effect corresponding the the postprocess.
  19840. */
  19841. getEffect(): Effect;
  19842. /**
  19843. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19844. * @param postProcess The post process to share the output with.
  19845. * @returns This post process.
  19846. */
  19847. shareOutputWith(postProcess: PostProcess): PostProcess;
  19848. /**
  19849. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19850. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19851. */
  19852. useOwnOutput(): void;
  19853. /**
  19854. * Updates the effect with the current post process compile time values and recompiles the shader.
  19855. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19856. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19857. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19858. * @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
  19859. * @param onCompiled Called when the shader has been compiled.
  19860. * @param onError Called if there is an error when compiling a shader.
  19861. */
  19862. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19863. /**
  19864. * The post process is reusable if it can be used multiple times within one frame.
  19865. * @returns If the post process is reusable
  19866. */
  19867. isReusable(): boolean;
  19868. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19869. markTextureDirty(): void;
  19870. /**
  19871. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19872. * 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.
  19873. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19874. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19875. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19876. * @returns The target texture that was bound to be written to.
  19877. */
  19878. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19879. /**
  19880. * If the post process is supported.
  19881. */
  19882. get isSupported(): boolean;
  19883. /**
  19884. * The aspect ratio of the output texture.
  19885. */
  19886. get aspectRatio(): number;
  19887. /**
  19888. * Get a value indicating if the post-process is ready to be used
  19889. * @returns true if the post-process is ready (shader is compiled)
  19890. */
  19891. isReady(): boolean;
  19892. /**
  19893. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19894. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19895. */
  19896. apply(): Nullable<Effect>;
  19897. private _disposeTextures;
  19898. /**
  19899. * Disposes the post process.
  19900. * @param camera The camera to dispose the post process on.
  19901. */
  19902. dispose(camera?: Camera): void;
  19903. }
  19904. }
  19905. declare module BABYLON {
  19906. /** @hidden */
  19907. export var kernelBlurVaryingDeclaration: {
  19908. name: string;
  19909. shader: string;
  19910. };
  19911. }
  19912. declare module BABYLON {
  19913. /** @hidden */
  19914. export var kernelBlurFragment: {
  19915. name: string;
  19916. shader: string;
  19917. };
  19918. }
  19919. declare module BABYLON {
  19920. /** @hidden */
  19921. export var kernelBlurFragment2: {
  19922. name: string;
  19923. shader: string;
  19924. };
  19925. }
  19926. declare module BABYLON {
  19927. /** @hidden */
  19928. export var kernelBlurPixelShader: {
  19929. name: string;
  19930. shader: string;
  19931. };
  19932. }
  19933. declare module BABYLON {
  19934. /** @hidden */
  19935. export var kernelBlurVertex: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module BABYLON {
  19941. /** @hidden */
  19942. export var kernelBlurVertexShader: {
  19943. name: string;
  19944. shader: string;
  19945. };
  19946. }
  19947. declare module BABYLON {
  19948. /**
  19949. * The Blur Post Process which blurs an image based on a kernel and direction.
  19950. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19951. */
  19952. export class BlurPostProcess extends PostProcess {
  19953. /** The direction in which to blur the image. */
  19954. direction: Vector2;
  19955. private blockCompilation;
  19956. protected _kernel: number;
  19957. protected _idealKernel: number;
  19958. protected _packedFloat: boolean;
  19959. private _staticDefines;
  19960. /**
  19961. * Sets the length in pixels of the blur sample region
  19962. */
  19963. set kernel(v: number);
  19964. /**
  19965. * Gets the length in pixels of the blur sample region
  19966. */
  19967. get kernel(): number;
  19968. /**
  19969. * Sets wether or not the blur needs to unpack/repack floats
  19970. */
  19971. set packedFloat(v: boolean);
  19972. /**
  19973. * Gets wether or not the blur is unpacking/repacking floats
  19974. */
  19975. get packedFloat(): boolean;
  19976. /**
  19977. * Creates a new instance BlurPostProcess
  19978. * @param name The name of the effect.
  19979. * @param direction The direction in which to blur the image.
  19980. * @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.
  19981. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19982. * @param camera The camera to apply the render pass to.
  19983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19984. * @param engine The engine which the post process will be applied. (default: current engine)
  19985. * @param reusable If the post process can be reused on the same frame. (default: false)
  19986. * @param textureType Type of textures used when performing the post process. (default: 0)
  19987. * @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)
  19988. */
  19989. constructor(name: string,
  19990. /** The direction in which to blur the image. */
  19991. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19992. /**
  19993. * Updates the effect with the current post process compile time values and recompiles the shader.
  19994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19997. * @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
  19998. * @param onCompiled Called when the shader has been compiled.
  19999. * @param onError Called if there is an error when compiling a shader.
  20000. */
  20001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20002. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20003. /**
  20004. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20005. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20006. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20007. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20008. * The gaps between physical kernels are compensated for in the weighting of the samples
  20009. * @param idealKernel Ideal blur kernel.
  20010. * @return Nearest best kernel.
  20011. */
  20012. protected _nearestBestKernel(idealKernel: number): number;
  20013. /**
  20014. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20015. * @param x The point on the Gaussian distribution to sample.
  20016. * @return the value of the Gaussian function at x.
  20017. */
  20018. protected _gaussianWeight(x: number): number;
  20019. /**
  20020. * Generates a string that can be used as a floating point number in GLSL.
  20021. * @param x Value to print.
  20022. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20023. * @return GLSL float string.
  20024. */
  20025. protected _glslFloat(x: number, decimalFigures?: number): string;
  20026. }
  20027. }
  20028. declare module BABYLON {
  20029. /**
  20030. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20031. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20032. * You can then easily use it as a reflectionTexture on a flat surface.
  20033. * In case the surface is not a plane, please consider relying on reflection probes.
  20034. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20035. */
  20036. export class MirrorTexture extends RenderTargetTexture {
  20037. private scene;
  20038. /**
  20039. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20040. * 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.
  20041. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20042. */
  20043. mirrorPlane: Plane;
  20044. /**
  20045. * Define the blur ratio used to blur the reflection if needed.
  20046. */
  20047. set blurRatio(value: number);
  20048. get blurRatio(): number;
  20049. /**
  20050. * Define the adaptive blur kernel used to blur the reflection if needed.
  20051. * This will autocompute the closest best match for the `blurKernel`
  20052. */
  20053. set adaptiveBlurKernel(value: number);
  20054. /**
  20055. * Define the blur kernel used to blur the reflection if needed.
  20056. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20057. */
  20058. set blurKernel(value: number);
  20059. /**
  20060. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20061. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20062. */
  20063. set blurKernelX(value: number);
  20064. get blurKernelX(): number;
  20065. /**
  20066. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20067. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20068. */
  20069. set blurKernelY(value: number);
  20070. get blurKernelY(): number;
  20071. private _autoComputeBlurKernel;
  20072. protected _onRatioRescale(): void;
  20073. private _updateGammaSpace;
  20074. private _imageProcessingConfigChangeObserver;
  20075. private _transformMatrix;
  20076. private _mirrorMatrix;
  20077. private _savedViewMatrix;
  20078. private _blurX;
  20079. private _blurY;
  20080. private _adaptiveBlurKernel;
  20081. private _blurKernelX;
  20082. private _blurKernelY;
  20083. private _blurRatio;
  20084. /**
  20085. * Instantiates a Mirror Texture.
  20086. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20087. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20088. * You can then easily use it as a reflectionTexture on a flat surface.
  20089. * In case the surface is not a plane, please consider relying on reflection probes.
  20090. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20091. * @param name
  20092. * @param size
  20093. * @param scene
  20094. * @param generateMipMaps
  20095. * @param type
  20096. * @param samplingMode
  20097. * @param generateDepthBuffer
  20098. */
  20099. constructor(name: string, size: number | {
  20100. width: number;
  20101. height: number;
  20102. } | {
  20103. ratio: number;
  20104. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20105. private _preparePostProcesses;
  20106. /**
  20107. * Clone the mirror texture.
  20108. * @returns the cloned texture
  20109. */
  20110. clone(): MirrorTexture;
  20111. /**
  20112. * Serialize the texture to a JSON representation you could use in Parse later on
  20113. * @returns the serialized JSON representation
  20114. */
  20115. serialize(): any;
  20116. /**
  20117. * Dispose the texture and release its associated resources.
  20118. */
  20119. dispose(): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20125. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20126. */
  20127. export class Texture extends BaseTexture {
  20128. /**
  20129. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20130. */
  20131. static SerializeBuffers: boolean;
  20132. /** @hidden */
  20133. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20134. /** @hidden */
  20135. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20136. /** @hidden */
  20137. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20138. /** nearest is mag = nearest and min = nearest and mip = linear */
  20139. static readonly NEAREST_SAMPLINGMODE: number;
  20140. /** nearest is mag = nearest and min = nearest and mip = linear */
  20141. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20142. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20143. static readonly BILINEAR_SAMPLINGMODE: number;
  20144. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20145. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20146. /** Trilinear is mag = linear and min = linear and mip = linear */
  20147. static readonly TRILINEAR_SAMPLINGMODE: number;
  20148. /** Trilinear is mag = linear and min = linear and mip = linear */
  20149. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20150. /** mag = nearest and min = nearest and mip = nearest */
  20151. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20152. /** mag = nearest and min = linear and mip = nearest */
  20153. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20154. /** mag = nearest and min = linear and mip = linear */
  20155. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20156. /** mag = nearest and min = linear and mip = none */
  20157. static readonly NEAREST_LINEAR: number;
  20158. /** mag = nearest and min = nearest and mip = none */
  20159. static readonly NEAREST_NEAREST: number;
  20160. /** mag = linear and min = nearest and mip = nearest */
  20161. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20162. /** mag = linear and min = nearest and mip = linear */
  20163. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20164. /** mag = linear and min = linear and mip = none */
  20165. static readonly LINEAR_LINEAR: number;
  20166. /** mag = linear and min = nearest and mip = none */
  20167. static readonly LINEAR_NEAREST: number;
  20168. /** Explicit coordinates mode */
  20169. static readonly EXPLICIT_MODE: number;
  20170. /** Spherical coordinates mode */
  20171. static readonly SPHERICAL_MODE: number;
  20172. /** Planar coordinates mode */
  20173. static readonly PLANAR_MODE: number;
  20174. /** Cubic coordinates mode */
  20175. static readonly CUBIC_MODE: number;
  20176. /** Projection coordinates mode */
  20177. static readonly PROJECTION_MODE: number;
  20178. /** Inverse Cubic coordinates mode */
  20179. static readonly SKYBOX_MODE: number;
  20180. /** Inverse Cubic coordinates mode */
  20181. static readonly INVCUBIC_MODE: number;
  20182. /** Equirectangular coordinates mode */
  20183. static readonly EQUIRECTANGULAR_MODE: number;
  20184. /** Equirectangular Fixed coordinates mode */
  20185. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20186. /** Equirectangular Fixed Mirrored coordinates mode */
  20187. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20188. /** Texture is not repeating outside of 0..1 UVs */
  20189. static readonly CLAMP_ADDRESSMODE: number;
  20190. /** Texture is repeating outside of 0..1 UVs */
  20191. static readonly WRAP_ADDRESSMODE: number;
  20192. /** Texture is repeating and mirrored */
  20193. static readonly MIRROR_ADDRESSMODE: number;
  20194. /**
  20195. * 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
  20196. */
  20197. static UseSerializedUrlIfAny: boolean;
  20198. /**
  20199. * Define the url of the texture.
  20200. */
  20201. url: Nullable<string>;
  20202. /**
  20203. * Define an offset on the texture to offset the u coordinates of the UVs
  20204. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20205. */
  20206. uOffset: number;
  20207. /**
  20208. * Define an offset on the texture to offset the v coordinates of the UVs
  20209. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20210. */
  20211. vOffset: number;
  20212. /**
  20213. * Define an offset on the texture to scale the u coordinates of the UVs
  20214. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20215. */
  20216. uScale: number;
  20217. /**
  20218. * Define an offset on the texture to scale the v coordinates of the UVs
  20219. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20220. */
  20221. vScale: number;
  20222. /**
  20223. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20224. * @see http://doc.babylonjs.com/how_to/more_materials
  20225. */
  20226. uAng: number;
  20227. /**
  20228. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20229. * @see http://doc.babylonjs.com/how_to/more_materials
  20230. */
  20231. vAng: number;
  20232. /**
  20233. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20234. * @see http://doc.babylonjs.com/how_to/more_materials
  20235. */
  20236. wAng: number;
  20237. /**
  20238. * Defines the center of rotation (U)
  20239. */
  20240. uRotationCenter: number;
  20241. /**
  20242. * Defines the center of rotation (V)
  20243. */
  20244. vRotationCenter: number;
  20245. /**
  20246. * Defines the center of rotation (W)
  20247. */
  20248. wRotationCenter: number;
  20249. /**
  20250. * Are mip maps generated for this texture or not.
  20251. */
  20252. get noMipmap(): boolean;
  20253. /**
  20254. * List of inspectable custom properties (used by the Inspector)
  20255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20256. */
  20257. inspectableCustomProperties: Nullable<IInspectable[]>;
  20258. private _noMipmap;
  20259. /** @hidden */
  20260. _invertY: boolean;
  20261. private _rowGenerationMatrix;
  20262. private _cachedTextureMatrix;
  20263. private _projectionModeMatrix;
  20264. private _t0;
  20265. private _t1;
  20266. private _t2;
  20267. private _cachedUOffset;
  20268. private _cachedVOffset;
  20269. private _cachedUScale;
  20270. private _cachedVScale;
  20271. private _cachedUAng;
  20272. private _cachedVAng;
  20273. private _cachedWAng;
  20274. private _cachedProjectionMatrixId;
  20275. private _cachedCoordinatesMode;
  20276. /** @hidden */
  20277. protected _initialSamplingMode: number;
  20278. /** @hidden */
  20279. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20280. private _deleteBuffer;
  20281. protected _format: Nullable<number>;
  20282. private _delayedOnLoad;
  20283. private _delayedOnError;
  20284. private _mimeType?;
  20285. /**
  20286. * Observable triggered once the texture has been loaded.
  20287. */
  20288. onLoadObservable: Observable<Texture>;
  20289. protected _isBlocking: boolean;
  20290. /**
  20291. * Is the texture preventing material to render while loading.
  20292. * If false, a default texture will be used instead of the loading one during the preparation step.
  20293. */
  20294. set isBlocking(value: boolean);
  20295. get isBlocking(): boolean;
  20296. /**
  20297. * Get the current sampling mode associated with the texture.
  20298. */
  20299. get samplingMode(): number;
  20300. /**
  20301. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20302. */
  20303. get invertY(): boolean;
  20304. /**
  20305. * Instantiates a new texture.
  20306. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20307. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20308. * @param url defines the url of the picture to load as a texture
  20309. * @param scene defines the scene or engine the texture will belong to
  20310. * @param noMipmap defines if the texture will require mip maps or not
  20311. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20312. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20313. * @param onLoad defines a callback triggered when the texture has been loaded
  20314. * @param onError defines a callback triggered when an error occurred during the loading session
  20315. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20316. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20317. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20318. * @param mimeType defines an optional mime type information
  20319. */
  20320. 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);
  20321. /**
  20322. * Update the url (and optional buffer) of this texture if url was null during construction.
  20323. * @param url the url of the texture
  20324. * @param buffer the buffer of the texture (defaults to null)
  20325. * @param onLoad callback called when the texture is loaded (defaults to null)
  20326. */
  20327. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20328. /**
  20329. * Finish the loading sequence of a texture flagged as delayed load.
  20330. * @hidden
  20331. */
  20332. delayLoad(): void;
  20333. private _prepareRowForTextureGeneration;
  20334. /**
  20335. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20336. * @returns the transform matrix of the texture.
  20337. */
  20338. getTextureMatrix(uBase?: number): Matrix;
  20339. /**
  20340. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20341. * @returns The reflection texture transform
  20342. */
  20343. getReflectionTextureMatrix(): Matrix;
  20344. /**
  20345. * Clones the texture.
  20346. * @returns the cloned texture
  20347. */
  20348. clone(): Texture;
  20349. /**
  20350. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20351. * @returns The JSON representation of the texture
  20352. */
  20353. serialize(): any;
  20354. /**
  20355. * Get the current class name of the texture useful for serialization or dynamic coding.
  20356. * @returns "Texture"
  20357. */
  20358. getClassName(): string;
  20359. /**
  20360. * Dispose the texture and release its associated resources.
  20361. */
  20362. dispose(): void;
  20363. /**
  20364. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20365. * @param parsedTexture Define the JSON representation of the texture
  20366. * @param scene Define the scene the parsed texture should be instantiated in
  20367. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20368. * @returns The parsed texture if successful
  20369. */
  20370. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20371. /**
  20372. * Creates a texture from its base 64 representation.
  20373. * @param data Define the base64 payload without the data: prefix
  20374. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20375. * @param scene Define the scene the texture should belong to
  20376. * @param noMipmap Forces the texture to not create mip map information if true
  20377. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20378. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20379. * @param onLoad define a callback triggered when the texture has been loaded
  20380. * @param onError define a callback triggered when an error occurred during the loading session
  20381. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20382. * @returns the created texture
  20383. */
  20384. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20385. /**
  20386. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20387. * @param data Define the base64 payload without the data: prefix
  20388. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20389. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20390. * @param scene Define the scene the texture should belong to
  20391. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20392. * @param noMipmap Forces the texture to not create mip map information if true
  20393. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20394. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20395. * @param onLoad define a callback triggered when the texture has been loaded
  20396. * @param onError define a callback triggered when an error occurred during the loading session
  20397. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20398. * @returns the created texture
  20399. */
  20400. 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;
  20401. }
  20402. }
  20403. declare module BABYLON {
  20404. /**
  20405. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20406. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20407. */
  20408. export class PostProcessManager {
  20409. private _scene;
  20410. private _indexBuffer;
  20411. private _vertexBuffers;
  20412. /**
  20413. * Creates a new instance PostProcess
  20414. * @param scene The scene that the post process is associated with.
  20415. */
  20416. constructor(scene: Scene);
  20417. private _prepareBuffers;
  20418. private _buildIndexBuffer;
  20419. /**
  20420. * Rebuilds the vertex buffers of the manager.
  20421. * @hidden
  20422. */
  20423. _rebuild(): void;
  20424. /**
  20425. * Prepares a frame to be run through a post process.
  20426. * @param sourceTexture The input texture to the post procesess. (default: null)
  20427. * @param postProcesses An array of post processes to be run. (default: null)
  20428. * @returns True if the post processes were able to be run.
  20429. * @hidden
  20430. */
  20431. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20432. /**
  20433. * Manually render a set of post processes to a texture.
  20434. * @param postProcesses An array of post processes to be run.
  20435. * @param targetTexture The target texture to render to.
  20436. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20437. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20438. * @param lodLevel defines which lod of the texture to render to
  20439. */
  20440. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20441. /**
  20442. * Finalize the result of the output of the postprocesses.
  20443. * @param doNotPresent If true the result will not be displayed to the screen.
  20444. * @param targetTexture The target texture to render to.
  20445. * @param faceIndex The index of the face to bind the target texture to.
  20446. * @param postProcesses The array of post processes to render.
  20447. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20448. * @hidden
  20449. */
  20450. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20451. /**
  20452. * Disposes of the post process manager.
  20453. */
  20454. dispose(): void;
  20455. }
  20456. }
  20457. declare module BABYLON {
  20458. /**
  20459. * This Helps creating a texture that will be created from a camera in your scene.
  20460. * It is basically a dynamic texture that could be used to create special effects for instance.
  20461. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20462. */
  20463. export class RenderTargetTexture extends Texture {
  20464. isCube: boolean;
  20465. /**
  20466. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20467. */
  20468. static readonly REFRESHRATE_RENDER_ONCE: number;
  20469. /**
  20470. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20471. */
  20472. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20473. /**
  20474. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20475. * the central point of your effect and can save a lot of performances.
  20476. */
  20477. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20478. /**
  20479. * Use this predicate to dynamically define the list of mesh you want to render.
  20480. * If set, the renderList property will be overwritten.
  20481. */
  20482. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20483. private _renderList;
  20484. /**
  20485. * Use this list to define the list of mesh you want to render.
  20486. */
  20487. get renderList(): Nullable<Array<AbstractMesh>>;
  20488. set renderList(value: Nullable<Array<AbstractMesh>>);
  20489. /**
  20490. * Use this function to overload the renderList array at rendering time.
  20491. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20492. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20493. * the cube (if the RTT is a cube, else layerOrFace=0).
  20494. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20495. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20496. * hold dummy elements!
  20497. */
  20498. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20499. private _hookArray;
  20500. /**
  20501. * Define if particles should be rendered in your texture.
  20502. */
  20503. renderParticles: boolean;
  20504. /**
  20505. * Define if sprites should be rendered in your texture.
  20506. */
  20507. renderSprites: boolean;
  20508. /**
  20509. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20510. */
  20511. coordinatesMode: number;
  20512. /**
  20513. * Define the camera used to render the texture.
  20514. */
  20515. activeCamera: Nullable<Camera>;
  20516. /**
  20517. * Override the render function of the texture with your own one.
  20518. */
  20519. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20520. /**
  20521. * Define if camera post processes should be use while rendering the texture.
  20522. */
  20523. useCameraPostProcesses: boolean;
  20524. /**
  20525. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20526. */
  20527. ignoreCameraViewport: boolean;
  20528. private _postProcessManager;
  20529. private _postProcesses;
  20530. private _resizeObserver;
  20531. /**
  20532. * An event triggered when the texture is unbind.
  20533. */
  20534. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20535. /**
  20536. * An event triggered when the texture is unbind.
  20537. */
  20538. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20539. private _onAfterUnbindObserver;
  20540. /**
  20541. * Set a after unbind callback in the texture.
  20542. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20543. */
  20544. set onAfterUnbind(callback: () => void);
  20545. /**
  20546. * An event triggered before rendering the texture
  20547. */
  20548. onBeforeRenderObservable: Observable<number>;
  20549. private _onBeforeRenderObserver;
  20550. /**
  20551. * Set a before render callback in the texture.
  20552. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20553. */
  20554. set onBeforeRender(callback: (faceIndex: number) => void);
  20555. /**
  20556. * An event triggered after rendering the texture
  20557. */
  20558. onAfterRenderObservable: Observable<number>;
  20559. private _onAfterRenderObserver;
  20560. /**
  20561. * Set a after render callback in the texture.
  20562. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20563. */
  20564. set onAfterRender(callback: (faceIndex: number) => void);
  20565. /**
  20566. * An event triggered after the texture clear
  20567. */
  20568. onClearObservable: Observable<Engine>;
  20569. private _onClearObserver;
  20570. /**
  20571. * Set a clear callback in the texture.
  20572. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20573. */
  20574. set onClear(callback: (Engine: Engine) => void);
  20575. /**
  20576. * An event triggered when the texture is resized.
  20577. */
  20578. onResizeObservable: Observable<RenderTargetTexture>;
  20579. /**
  20580. * Define the clear color of the Render Target if it should be different from the scene.
  20581. */
  20582. clearColor: Color4;
  20583. protected _size: number | {
  20584. width: number;
  20585. height: number;
  20586. layers?: number;
  20587. };
  20588. protected _initialSizeParameter: number | {
  20589. width: number;
  20590. height: number;
  20591. } | {
  20592. ratio: number;
  20593. };
  20594. protected _sizeRatio: Nullable<number>;
  20595. /** @hidden */
  20596. _generateMipMaps: boolean;
  20597. protected _renderingManager: RenderingManager;
  20598. /** @hidden */
  20599. _waitingRenderList: string[];
  20600. protected _doNotChangeAspectRatio: boolean;
  20601. protected _currentRefreshId: number;
  20602. protected _refreshRate: number;
  20603. protected _textureMatrix: Matrix;
  20604. protected _samples: number;
  20605. protected _renderTargetOptions: RenderTargetCreationOptions;
  20606. /**
  20607. * Gets render target creation options that were used.
  20608. */
  20609. get renderTargetOptions(): RenderTargetCreationOptions;
  20610. protected _engine: Engine;
  20611. protected _onRatioRescale(): void;
  20612. /**
  20613. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20614. * It must define where the camera used to render the texture is set
  20615. */
  20616. boundingBoxPosition: Vector3;
  20617. private _boundingBoxSize;
  20618. /**
  20619. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20620. * When defined, the cubemap will switch to local mode
  20621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20622. * @example https://www.babylonjs-playground.com/#RNASML
  20623. */
  20624. set boundingBoxSize(value: Vector3);
  20625. get boundingBoxSize(): Vector3;
  20626. /**
  20627. * In case the RTT has been created with a depth texture, get the associated
  20628. * depth texture.
  20629. * Otherwise, return null.
  20630. */
  20631. get depthStencilTexture(): Nullable<InternalTexture>;
  20632. /**
  20633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20634. * or used a shadow, depth texture...
  20635. * @param name The friendly name of the texture
  20636. * @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)
  20637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20638. * @param generateMipMaps True if mip maps need to be generated after render.
  20639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20640. * @param type The type of the buffer in the RTT (int, half float, float...)
  20641. * @param isCube True if a cube texture needs to be created
  20642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20643. * @param generateDepthBuffer True to generate a depth buffer
  20644. * @param generateStencilBuffer True to generate a stencil buffer
  20645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20648. */
  20649. constructor(name: string, size: number | {
  20650. width: number;
  20651. height: number;
  20652. layers?: number;
  20653. } | {
  20654. ratio: number;
  20655. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20656. /**
  20657. * Creates a depth stencil texture.
  20658. * This is only available in WebGL 2 or with the depth texture extension available.
  20659. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20660. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20661. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20662. */
  20663. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20664. private _processSizeParameter;
  20665. /**
  20666. * Define the number of samples to use in case of MSAA.
  20667. * It defaults to one meaning no MSAA has been enabled.
  20668. */
  20669. get samples(): number;
  20670. set samples(value: number);
  20671. /**
  20672. * Resets the refresh counter of the texture and start bak from scratch.
  20673. * Could be useful to regenerate the texture if it is setup to render only once.
  20674. */
  20675. resetRefreshCounter(): void;
  20676. /**
  20677. * Define the refresh rate of the texture or the rendering frequency.
  20678. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20679. */
  20680. get refreshRate(): number;
  20681. set refreshRate(value: number);
  20682. /**
  20683. * Adds a post process to the render target rendering passes.
  20684. * @param postProcess define the post process to add
  20685. */
  20686. addPostProcess(postProcess: PostProcess): void;
  20687. /**
  20688. * Clear all the post processes attached to the render target
  20689. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20690. */
  20691. clearPostProcesses(dispose?: boolean): void;
  20692. /**
  20693. * Remove one of the post process from the list of attached post processes to the texture
  20694. * @param postProcess define the post process to remove from the list
  20695. */
  20696. removePostProcess(postProcess: PostProcess): void;
  20697. /** @hidden */
  20698. _shouldRender(): boolean;
  20699. /**
  20700. * Gets the actual render size of the texture.
  20701. * @returns the width of the render size
  20702. */
  20703. getRenderSize(): number;
  20704. /**
  20705. * Gets the actual render width of the texture.
  20706. * @returns the width of the render size
  20707. */
  20708. getRenderWidth(): number;
  20709. /**
  20710. * Gets the actual render height of the texture.
  20711. * @returns the height of the render size
  20712. */
  20713. getRenderHeight(): number;
  20714. /**
  20715. * Gets the actual number of layers of the texture.
  20716. * @returns the number of layers
  20717. */
  20718. getRenderLayers(): number;
  20719. /**
  20720. * Get if the texture can be rescaled or not.
  20721. */
  20722. get canRescale(): boolean;
  20723. /**
  20724. * Resize the texture using a ratio.
  20725. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20726. */
  20727. scale(ratio: number): void;
  20728. /**
  20729. * Get the texture reflection matrix used to rotate/transform the reflection.
  20730. * @returns the reflection matrix
  20731. */
  20732. getReflectionTextureMatrix(): Matrix;
  20733. /**
  20734. * Resize the texture to a new desired size.
  20735. * Be carrefull as it will recreate all the data in the new texture.
  20736. * @param size Define the new size. It can be:
  20737. * - a number for squared texture,
  20738. * - an object containing { width: number, height: number }
  20739. * - or an object containing a ratio { ratio: number }
  20740. */
  20741. resize(size: number | {
  20742. width: number;
  20743. height: number;
  20744. } | {
  20745. ratio: number;
  20746. }): void;
  20747. private _defaultRenderListPrepared;
  20748. /**
  20749. * Renders all the objects from the render list into the texture.
  20750. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20751. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20752. */
  20753. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20754. private _bestReflectionRenderTargetDimension;
  20755. private _prepareRenderingManager;
  20756. /**
  20757. * @hidden
  20758. * @param faceIndex face index to bind to if this is a cubetexture
  20759. * @param layer defines the index of the texture to bind in the array
  20760. */
  20761. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20762. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20763. private renderToTarget;
  20764. /**
  20765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20766. * This allowed control for front to back rendering or reversly depending of the special needs.
  20767. *
  20768. * @param renderingGroupId The rendering group id corresponding to its index
  20769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20772. */
  20773. 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;
  20774. /**
  20775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20776. *
  20777. * @param renderingGroupId The rendering group id corresponding to its index
  20778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20779. */
  20780. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20781. /**
  20782. * Clones the texture.
  20783. * @returns the cloned texture
  20784. */
  20785. clone(): RenderTargetTexture;
  20786. /**
  20787. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20788. * @returns The JSON representation of the texture
  20789. */
  20790. serialize(): any;
  20791. /**
  20792. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20793. */
  20794. disposeFramebufferObjects(): void;
  20795. /**
  20796. * Dispose the texture and release its associated resources.
  20797. */
  20798. dispose(): void;
  20799. /** @hidden */
  20800. _rebuild(): void;
  20801. /**
  20802. * Clear the info related to rendering groups preventing retention point in material dispose.
  20803. */
  20804. freeRenderingGroups(): void;
  20805. /**
  20806. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20807. * @returns the view count
  20808. */
  20809. getViewCount(): number;
  20810. }
  20811. }
  20812. declare module BABYLON {
  20813. /**
  20814. * Options for compiling materials.
  20815. */
  20816. export interface IMaterialCompilationOptions {
  20817. /**
  20818. * Defines whether clip planes are enabled.
  20819. */
  20820. clipPlane: boolean;
  20821. /**
  20822. * Defines whether instances are enabled.
  20823. */
  20824. useInstances: boolean;
  20825. }
  20826. /**
  20827. * Base class for the main features of a material in Babylon.js
  20828. */
  20829. export class Material implements IAnimatable {
  20830. /**
  20831. * Returns the triangle fill mode
  20832. */
  20833. static readonly TriangleFillMode: number;
  20834. /**
  20835. * Returns the wireframe mode
  20836. */
  20837. static readonly WireFrameFillMode: number;
  20838. /**
  20839. * Returns the point fill mode
  20840. */
  20841. static readonly PointFillMode: number;
  20842. /**
  20843. * Returns the point list draw mode
  20844. */
  20845. static readonly PointListDrawMode: number;
  20846. /**
  20847. * Returns the line list draw mode
  20848. */
  20849. static readonly LineListDrawMode: number;
  20850. /**
  20851. * Returns the line loop draw mode
  20852. */
  20853. static readonly LineLoopDrawMode: number;
  20854. /**
  20855. * Returns the line strip draw mode
  20856. */
  20857. static readonly LineStripDrawMode: number;
  20858. /**
  20859. * Returns the triangle strip draw mode
  20860. */
  20861. static readonly TriangleStripDrawMode: number;
  20862. /**
  20863. * Returns the triangle fan draw mode
  20864. */
  20865. static readonly TriangleFanDrawMode: number;
  20866. /**
  20867. * Stores the clock-wise side orientation
  20868. */
  20869. static readonly ClockWiseSideOrientation: number;
  20870. /**
  20871. * Stores the counter clock-wise side orientation
  20872. */
  20873. static readonly CounterClockWiseSideOrientation: number;
  20874. /**
  20875. * The dirty texture flag value
  20876. */
  20877. static readonly TextureDirtyFlag: number;
  20878. /**
  20879. * The dirty light flag value
  20880. */
  20881. static readonly LightDirtyFlag: number;
  20882. /**
  20883. * The dirty fresnel flag value
  20884. */
  20885. static readonly FresnelDirtyFlag: number;
  20886. /**
  20887. * The dirty attribute flag value
  20888. */
  20889. static readonly AttributesDirtyFlag: number;
  20890. /**
  20891. * The dirty misc flag value
  20892. */
  20893. static readonly MiscDirtyFlag: number;
  20894. /**
  20895. * The all dirty flag value
  20896. */
  20897. static readonly AllDirtyFlag: number;
  20898. /**
  20899. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20900. */
  20901. static readonly MATERIAL_OPAQUE: number;
  20902. /**
  20903. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20904. */
  20905. static readonly MATERIAL_ALPHATEST: number;
  20906. /**
  20907. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20908. */
  20909. static readonly MATERIAL_ALPHABLEND: number;
  20910. /**
  20911. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20912. * They are also discarded below the alpha cutoff threshold to improve performances.
  20913. */
  20914. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  20915. /**
  20916. * The ID of the material
  20917. */
  20918. id: string;
  20919. /**
  20920. * Gets or sets the unique id of the material
  20921. */
  20922. uniqueId: number;
  20923. /**
  20924. * The name of the material
  20925. */
  20926. name: string;
  20927. /**
  20928. * Gets or sets user defined metadata
  20929. */
  20930. metadata: any;
  20931. /**
  20932. * For internal use only. Please do not use.
  20933. */
  20934. reservedDataStore: any;
  20935. /**
  20936. * Specifies if the ready state should be checked on each call
  20937. */
  20938. checkReadyOnEveryCall: boolean;
  20939. /**
  20940. * Specifies if the ready state should be checked once
  20941. */
  20942. checkReadyOnlyOnce: boolean;
  20943. /**
  20944. * The state of the material
  20945. */
  20946. state: string;
  20947. /**
  20948. * The alpha value of the material
  20949. */
  20950. protected _alpha: number;
  20951. /**
  20952. * List of inspectable custom properties (used by the Inspector)
  20953. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20954. */
  20955. inspectableCustomProperties: IInspectable[];
  20956. /**
  20957. * Sets the alpha value of the material
  20958. */
  20959. set alpha(value: number);
  20960. /**
  20961. * Gets the alpha value of the material
  20962. */
  20963. get alpha(): number;
  20964. /**
  20965. * Specifies if back face culling is enabled
  20966. */
  20967. protected _backFaceCulling: boolean;
  20968. /**
  20969. * Sets the back-face culling state
  20970. */
  20971. set backFaceCulling(value: boolean);
  20972. /**
  20973. * Gets the back-face culling state
  20974. */
  20975. get backFaceCulling(): boolean;
  20976. /**
  20977. * Stores the value for side orientation
  20978. */
  20979. sideOrientation: number;
  20980. /**
  20981. * Callback triggered when the material is compiled
  20982. */
  20983. onCompiled: Nullable<(effect: Effect) => void>;
  20984. /**
  20985. * Callback triggered when an error occurs
  20986. */
  20987. onError: Nullable<(effect: Effect, errors: string) => void>;
  20988. /**
  20989. * Callback triggered to get the render target textures
  20990. */
  20991. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20992. /**
  20993. * Gets a boolean indicating that current material needs to register RTT
  20994. */
  20995. get hasRenderTargetTextures(): boolean;
  20996. /**
  20997. * Specifies if the material should be serialized
  20998. */
  20999. doNotSerialize: boolean;
  21000. /**
  21001. * @hidden
  21002. */
  21003. _storeEffectOnSubMeshes: boolean;
  21004. /**
  21005. * Stores the animations for the material
  21006. */
  21007. animations: Nullable<Array<Animation>>;
  21008. /**
  21009. * An event triggered when the material is disposed
  21010. */
  21011. onDisposeObservable: Observable<Material>;
  21012. /**
  21013. * An observer which watches for dispose events
  21014. */
  21015. private _onDisposeObserver;
  21016. private _onUnBindObservable;
  21017. /**
  21018. * Called during a dispose event
  21019. */
  21020. set onDispose(callback: () => void);
  21021. private _onBindObservable;
  21022. /**
  21023. * An event triggered when the material is bound
  21024. */
  21025. get onBindObservable(): Observable<AbstractMesh>;
  21026. /**
  21027. * An observer which watches for bind events
  21028. */
  21029. private _onBindObserver;
  21030. /**
  21031. * Called during a bind event
  21032. */
  21033. set onBind(callback: (Mesh: AbstractMesh) => void);
  21034. /**
  21035. * An event triggered when the material is unbound
  21036. */
  21037. get onUnBindObservable(): Observable<Material>;
  21038. /**
  21039. * Stores the value of the alpha mode
  21040. */
  21041. private _alphaMode;
  21042. /**
  21043. * Sets the value of the alpha mode.
  21044. *
  21045. * | Value | Type | Description |
  21046. * | --- | --- | --- |
  21047. * | 0 | ALPHA_DISABLE | |
  21048. * | 1 | ALPHA_ADD | |
  21049. * | 2 | ALPHA_COMBINE | |
  21050. * | 3 | ALPHA_SUBTRACT | |
  21051. * | 4 | ALPHA_MULTIPLY | |
  21052. * | 5 | ALPHA_MAXIMIZED | |
  21053. * | 6 | ALPHA_ONEONE | |
  21054. * | 7 | ALPHA_PREMULTIPLIED | |
  21055. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21056. * | 9 | ALPHA_INTERPOLATE | |
  21057. * | 10 | ALPHA_SCREENMODE | |
  21058. *
  21059. */
  21060. set alphaMode(value: number);
  21061. /**
  21062. * Gets the value of the alpha mode
  21063. */
  21064. get alphaMode(): number;
  21065. /**
  21066. * Stores the state of the need depth pre-pass value
  21067. */
  21068. private _needDepthPrePass;
  21069. /**
  21070. * Sets the need depth pre-pass value
  21071. */
  21072. set needDepthPrePass(value: boolean);
  21073. /**
  21074. * Gets the depth pre-pass value
  21075. */
  21076. get needDepthPrePass(): boolean;
  21077. /**
  21078. * Specifies if depth writing should be disabled
  21079. */
  21080. disableDepthWrite: boolean;
  21081. /**
  21082. * Specifies if depth writing should be forced
  21083. */
  21084. forceDepthWrite: boolean;
  21085. /**
  21086. * Specifies the depth function that should be used. 0 means the default engine function
  21087. */
  21088. depthFunction: number;
  21089. /**
  21090. * Specifies if there should be a separate pass for culling
  21091. */
  21092. separateCullingPass: boolean;
  21093. /**
  21094. * Stores the state specifing if fog should be enabled
  21095. */
  21096. private _fogEnabled;
  21097. /**
  21098. * Sets the state for enabling fog
  21099. */
  21100. set fogEnabled(value: boolean);
  21101. /**
  21102. * Gets the value of the fog enabled state
  21103. */
  21104. get fogEnabled(): boolean;
  21105. /**
  21106. * Stores the size of points
  21107. */
  21108. pointSize: number;
  21109. /**
  21110. * Stores the z offset value
  21111. */
  21112. zOffset: number;
  21113. /**
  21114. * Gets a value specifying if wireframe mode is enabled
  21115. */
  21116. get wireframe(): boolean;
  21117. /**
  21118. * Sets the state of wireframe mode
  21119. */
  21120. set wireframe(value: boolean);
  21121. /**
  21122. * Gets the value specifying if point clouds are enabled
  21123. */
  21124. get pointsCloud(): boolean;
  21125. /**
  21126. * Sets the state of point cloud mode
  21127. */
  21128. set pointsCloud(value: boolean);
  21129. /**
  21130. * Gets the material fill mode
  21131. */
  21132. get fillMode(): number;
  21133. /**
  21134. * Sets the material fill mode
  21135. */
  21136. set fillMode(value: number);
  21137. /**
  21138. * @hidden
  21139. * Stores the effects for the material
  21140. */
  21141. _effect: Nullable<Effect>;
  21142. /**
  21143. * Specifies if uniform buffers should be used
  21144. */
  21145. private _useUBO;
  21146. /**
  21147. * Stores a reference to the scene
  21148. */
  21149. private _scene;
  21150. /**
  21151. * Stores the fill mode state
  21152. */
  21153. private _fillMode;
  21154. /**
  21155. * Specifies if the depth write state should be cached
  21156. */
  21157. private _cachedDepthWriteState;
  21158. /**
  21159. * Specifies if the depth function state should be cached
  21160. */
  21161. private _cachedDepthFunctionState;
  21162. /**
  21163. * Stores the uniform buffer
  21164. */
  21165. protected _uniformBuffer: UniformBuffer;
  21166. /** @hidden */
  21167. _indexInSceneMaterialArray: number;
  21168. /** @hidden */
  21169. meshMap: Nullable<{
  21170. [id: string]: AbstractMesh | undefined;
  21171. }>;
  21172. /**
  21173. * Creates a material instance
  21174. * @param name defines the name of the material
  21175. * @param scene defines the scene to reference
  21176. * @param doNotAdd specifies if the material should be added to the scene
  21177. */
  21178. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21179. /**
  21180. * Returns a string representation of the current material
  21181. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21182. * @returns a string with material information
  21183. */
  21184. toString(fullDetails?: boolean): string;
  21185. /**
  21186. * Gets the class name of the material
  21187. * @returns a string with the class name of the material
  21188. */
  21189. getClassName(): string;
  21190. /**
  21191. * Specifies if updates for the material been locked
  21192. */
  21193. get isFrozen(): boolean;
  21194. /**
  21195. * Locks updates for the material
  21196. */
  21197. freeze(): void;
  21198. /**
  21199. * Unlocks updates for the material
  21200. */
  21201. unfreeze(): void;
  21202. /**
  21203. * Specifies if the material is ready to be used
  21204. * @param mesh defines the mesh to check
  21205. * @param useInstances specifies if instances should be used
  21206. * @returns a boolean indicating if the material is ready to be used
  21207. */
  21208. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21209. /**
  21210. * Specifies that the submesh is ready to be used
  21211. * @param mesh defines the mesh to check
  21212. * @param subMesh defines which submesh to check
  21213. * @param useInstances specifies that instances should be used
  21214. * @returns a boolean indicating that the submesh is ready or not
  21215. */
  21216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21217. /**
  21218. * Returns the material effect
  21219. * @returns the effect associated with the material
  21220. */
  21221. getEffect(): Nullable<Effect>;
  21222. /**
  21223. * Returns the current scene
  21224. * @returns a Scene
  21225. */
  21226. getScene(): Scene;
  21227. /**
  21228. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21229. */
  21230. protected _forceAlphaTest: boolean;
  21231. /**
  21232. * The transparency mode of the material.
  21233. */
  21234. protected _transparencyMode: Nullable<number>;
  21235. /**
  21236. * Gets the current transparency mode.
  21237. */
  21238. get transparencyMode(): Nullable<number>;
  21239. /**
  21240. * Sets the transparency mode of the material.
  21241. *
  21242. * | Value | Type | Description |
  21243. * | ----- | ----------------------------------- | ----------- |
  21244. * | 0 | OPAQUE | |
  21245. * | 1 | ALPHATEST | |
  21246. * | 2 | ALPHABLEND | |
  21247. * | 3 | ALPHATESTANDBLEND | |
  21248. *
  21249. */
  21250. set transparencyMode(value: Nullable<number>);
  21251. /**
  21252. * Returns true if alpha blending should be disabled.
  21253. */
  21254. protected get _disableAlphaBlending(): boolean;
  21255. /**
  21256. * Specifies whether or not this material should be rendered in alpha blend mode.
  21257. * @returns a boolean specifying if alpha blending is needed
  21258. */
  21259. needAlphaBlending(): boolean;
  21260. /**
  21261. * Specifies if the mesh will require alpha blending
  21262. * @param mesh defines the mesh to check
  21263. * @returns a boolean specifying if alpha blending is needed for the mesh
  21264. */
  21265. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21266. /**
  21267. * Specifies whether or not this material should be rendered in alpha test mode.
  21268. * @returns a boolean specifying if an alpha test is needed.
  21269. */
  21270. needAlphaTesting(): boolean;
  21271. /**
  21272. * Specifies if material alpha testing should be turned on for the mesh
  21273. * @param mesh defines the mesh to check
  21274. */
  21275. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21276. /**
  21277. * Gets the texture used for the alpha test
  21278. * @returns the texture to use for alpha testing
  21279. */
  21280. getAlphaTestTexture(): Nullable<BaseTexture>;
  21281. /**
  21282. * Marks the material to indicate that it needs to be re-calculated
  21283. */
  21284. markDirty(): void;
  21285. /** @hidden */
  21286. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21287. /**
  21288. * Binds the material to the mesh
  21289. * @param world defines the world transformation matrix
  21290. * @param mesh defines the mesh to bind the material to
  21291. */
  21292. bind(world: Matrix, mesh?: Mesh): void;
  21293. /**
  21294. * Binds the submesh to the material
  21295. * @param world defines the world transformation matrix
  21296. * @param mesh defines the mesh containing the submesh
  21297. * @param subMesh defines the submesh to bind the material to
  21298. */
  21299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21300. /**
  21301. * Binds the world matrix to the material
  21302. * @param world defines the world transformation matrix
  21303. */
  21304. bindOnlyWorldMatrix(world: Matrix): void;
  21305. /**
  21306. * Binds the scene's uniform buffer to the effect.
  21307. * @param effect defines the effect to bind to the scene uniform buffer
  21308. * @param sceneUbo defines the uniform buffer storing scene data
  21309. */
  21310. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21311. /**
  21312. * Binds the view matrix to the effect
  21313. * @param effect defines the effect to bind the view matrix to
  21314. */
  21315. bindView(effect: Effect): void;
  21316. /**
  21317. * Binds the view projection matrix to the effect
  21318. * @param effect defines the effect to bind the view projection matrix to
  21319. */
  21320. bindViewProjection(effect: Effect): void;
  21321. /**
  21322. * Processes to execute after binding the material to a mesh
  21323. * @param mesh defines the rendered mesh
  21324. */
  21325. protected _afterBind(mesh?: Mesh): void;
  21326. /**
  21327. * Unbinds the material from the mesh
  21328. */
  21329. unbind(): void;
  21330. /**
  21331. * Gets the active textures from the material
  21332. * @returns an array of textures
  21333. */
  21334. getActiveTextures(): BaseTexture[];
  21335. /**
  21336. * Specifies if the material uses a texture
  21337. * @param texture defines the texture to check against the material
  21338. * @returns a boolean specifying if the material uses the texture
  21339. */
  21340. hasTexture(texture: BaseTexture): boolean;
  21341. /**
  21342. * Makes a duplicate of the material, and gives it a new name
  21343. * @param name defines the new name for the duplicated material
  21344. * @returns the cloned material
  21345. */
  21346. clone(name: string): Nullable<Material>;
  21347. /**
  21348. * Gets the meshes bound to the material
  21349. * @returns an array of meshes bound to the material
  21350. */
  21351. getBindedMeshes(): AbstractMesh[];
  21352. /**
  21353. * Force shader compilation
  21354. * @param mesh defines the mesh associated with this material
  21355. * @param onCompiled defines a function to execute once the material is compiled
  21356. * @param options defines the options to configure the compilation
  21357. * @param onError defines a function to execute if the material fails compiling
  21358. */
  21359. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21360. /**
  21361. * Force shader compilation
  21362. * @param mesh defines the mesh that will use this material
  21363. * @param options defines additional options for compiling the shaders
  21364. * @returns a promise that resolves when the compilation completes
  21365. */
  21366. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21367. private static readonly _AllDirtyCallBack;
  21368. private static readonly _ImageProcessingDirtyCallBack;
  21369. private static readonly _TextureDirtyCallBack;
  21370. private static readonly _FresnelDirtyCallBack;
  21371. private static readonly _MiscDirtyCallBack;
  21372. private static readonly _LightsDirtyCallBack;
  21373. private static readonly _AttributeDirtyCallBack;
  21374. private static _FresnelAndMiscDirtyCallBack;
  21375. private static _TextureAndMiscDirtyCallBack;
  21376. private static readonly _DirtyCallbackArray;
  21377. private static readonly _RunDirtyCallBacks;
  21378. /**
  21379. * Marks a define in the material to indicate that it needs to be re-computed
  21380. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21381. */
  21382. markAsDirty(flag: number): void;
  21383. /**
  21384. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21385. * @param func defines a function which checks material defines against the submeshes
  21386. */
  21387. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21388. /**
  21389. * Indicates that we need to re-calculated for all submeshes
  21390. */
  21391. protected _markAllSubMeshesAsAllDirty(): void;
  21392. /**
  21393. * Indicates that image processing needs to be re-calculated for all submeshes
  21394. */
  21395. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21396. /**
  21397. * Indicates that textures need to be re-calculated for all submeshes
  21398. */
  21399. protected _markAllSubMeshesAsTexturesDirty(): void;
  21400. /**
  21401. * Indicates that fresnel needs to be re-calculated for all submeshes
  21402. */
  21403. protected _markAllSubMeshesAsFresnelDirty(): void;
  21404. /**
  21405. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21406. */
  21407. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21408. /**
  21409. * Indicates that lights need to be re-calculated for all submeshes
  21410. */
  21411. protected _markAllSubMeshesAsLightsDirty(): void;
  21412. /**
  21413. * Indicates that attributes need to be re-calculated for all submeshes
  21414. */
  21415. protected _markAllSubMeshesAsAttributesDirty(): void;
  21416. /**
  21417. * Indicates that misc needs to be re-calculated for all submeshes
  21418. */
  21419. protected _markAllSubMeshesAsMiscDirty(): void;
  21420. /**
  21421. * Indicates that textures and misc need to be re-calculated for all submeshes
  21422. */
  21423. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21424. /**
  21425. * Disposes the material
  21426. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21427. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21428. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21429. */
  21430. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21431. /** @hidden */
  21432. private releaseVertexArrayObject;
  21433. /**
  21434. * Serializes this material
  21435. * @returns the serialized material object
  21436. */
  21437. serialize(): any;
  21438. /**
  21439. * Creates a material from parsed material data
  21440. * @param parsedMaterial defines parsed material data
  21441. * @param scene defines the hosting scene
  21442. * @param rootUrl defines the root URL to use to load textures
  21443. * @returns a new material
  21444. */
  21445. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21446. }
  21447. }
  21448. declare module BABYLON {
  21449. /**
  21450. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21451. * separate meshes. This can be use to improve performances.
  21452. * @see http://doc.babylonjs.com/how_to/multi_materials
  21453. */
  21454. export class MultiMaterial extends Material {
  21455. private _subMaterials;
  21456. /**
  21457. * Gets or Sets the list of Materials used within the multi material.
  21458. * They need to be ordered according to the submeshes order in the associated mesh
  21459. */
  21460. get subMaterials(): Nullable<Material>[];
  21461. set subMaterials(value: Nullable<Material>[]);
  21462. /**
  21463. * Function used to align with Node.getChildren()
  21464. * @returns the list of Materials used within the multi material
  21465. */
  21466. getChildren(): Nullable<Material>[];
  21467. /**
  21468. * Instantiates a new Multi Material
  21469. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21470. * separate meshes. This can be use to improve performances.
  21471. * @see http://doc.babylonjs.com/how_to/multi_materials
  21472. * @param name Define the name in the scene
  21473. * @param scene Define the scene the material belongs to
  21474. */
  21475. constructor(name: string, scene: Scene);
  21476. private _hookArray;
  21477. /**
  21478. * Get one of the submaterial by its index in the submaterials array
  21479. * @param index The index to look the sub material at
  21480. * @returns The Material if the index has been defined
  21481. */
  21482. getSubMaterial(index: number): Nullable<Material>;
  21483. /**
  21484. * Get the list of active textures for the whole sub materials list.
  21485. * @returns All the textures that will be used during the rendering
  21486. */
  21487. getActiveTextures(): BaseTexture[];
  21488. /**
  21489. * Gets the current class name of the material e.g. "MultiMaterial"
  21490. * Mainly use in serialization.
  21491. * @returns the class name
  21492. */
  21493. getClassName(): string;
  21494. /**
  21495. * Checks if the material is ready to render the requested sub mesh
  21496. * @param mesh Define the mesh the submesh belongs to
  21497. * @param subMesh Define the sub mesh to look readyness for
  21498. * @param useInstances Define whether or not the material is used with instances
  21499. * @returns true if ready, otherwise false
  21500. */
  21501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21502. /**
  21503. * Clones the current material and its related sub materials
  21504. * @param name Define the name of the newly cloned material
  21505. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21506. * @returns the cloned material
  21507. */
  21508. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21509. /**
  21510. * Serializes the materials into a JSON representation.
  21511. * @returns the JSON representation
  21512. */
  21513. serialize(): any;
  21514. /**
  21515. * Dispose the material and release its associated resources
  21516. * @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)
  21517. * @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)
  21518. * @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)
  21519. */
  21520. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21521. /**
  21522. * Creates a MultiMaterial from parsed MultiMaterial data.
  21523. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21524. * @param scene defines the hosting scene
  21525. * @returns a new MultiMaterial
  21526. */
  21527. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21528. }
  21529. }
  21530. declare module BABYLON {
  21531. /**
  21532. * Base class for submeshes
  21533. */
  21534. export class BaseSubMesh {
  21535. /** @hidden */
  21536. _materialDefines: Nullable<MaterialDefines>;
  21537. /** @hidden */
  21538. _materialEffect: Nullable<Effect>;
  21539. /**
  21540. * Gets material defines used by the effect associated to the sub mesh
  21541. */
  21542. get materialDefines(): Nullable<MaterialDefines>;
  21543. /**
  21544. * Sets material defines used by the effect associated to the sub mesh
  21545. */
  21546. set materialDefines(defines: Nullable<MaterialDefines>);
  21547. /**
  21548. * Gets associated effect
  21549. */
  21550. get effect(): Nullable<Effect>;
  21551. /**
  21552. * Sets associated effect (effect used to render this submesh)
  21553. * @param effect defines the effect to associate with
  21554. * @param defines defines the set of defines used to compile this effect
  21555. */
  21556. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21557. }
  21558. /**
  21559. * Defines a subdivision inside a mesh
  21560. */
  21561. export class SubMesh extends BaseSubMesh implements ICullable {
  21562. /** the material index to use */
  21563. materialIndex: number;
  21564. /** vertex index start */
  21565. verticesStart: number;
  21566. /** vertices count */
  21567. verticesCount: number;
  21568. /** index start */
  21569. indexStart: number;
  21570. /** indices count */
  21571. indexCount: number;
  21572. /** @hidden */
  21573. _linesIndexCount: number;
  21574. private _mesh;
  21575. private _renderingMesh;
  21576. private _boundingInfo;
  21577. private _linesIndexBuffer;
  21578. /** @hidden */
  21579. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21580. /** @hidden */
  21581. _trianglePlanes: Plane[];
  21582. /** @hidden */
  21583. _lastColliderTransformMatrix: Nullable<Matrix>;
  21584. /** @hidden */
  21585. _renderId: number;
  21586. /** @hidden */
  21587. _alphaIndex: number;
  21588. /** @hidden */
  21589. _distanceToCamera: number;
  21590. /** @hidden */
  21591. _id: number;
  21592. private _currentMaterial;
  21593. /**
  21594. * Add a new submesh to a mesh
  21595. * @param materialIndex defines the material index to use
  21596. * @param verticesStart defines vertex index start
  21597. * @param verticesCount defines vertices count
  21598. * @param indexStart defines index start
  21599. * @param indexCount defines indices count
  21600. * @param mesh defines the parent mesh
  21601. * @param renderingMesh defines an optional rendering mesh
  21602. * @param createBoundingBox defines if bounding box should be created for this submesh
  21603. * @returns the new submesh
  21604. */
  21605. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21606. /**
  21607. * Creates a new submesh
  21608. * @param materialIndex defines the material index to use
  21609. * @param verticesStart defines vertex index start
  21610. * @param verticesCount defines vertices count
  21611. * @param indexStart defines index start
  21612. * @param indexCount defines indices count
  21613. * @param mesh defines the parent mesh
  21614. * @param renderingMesh defines an optional rendering mesh
  21615. * @param createBoundingBox defines if bounding box should be created for this submesh
  21616. */
  21617. constructor(
  21618. /** the material index to use */
  21619. materialIndex: number,
  21620. /** vertex index start */
  21621. verticesStart: number,
  21622. /** vertices count */
  21623. verticesCount: number,
  21624. /** index start */
  21625. indexStart: number,
  21626. /** indices count */
  21627. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21628. /**
  21629. * Returns true if this submesh covers the entire parent mesh
  21630. * @ignorenaming
  21631. */
  21632. get IsGlobal(): boolean;
  21633. /**
  21634. * Returns the submesh BoudingInfo object
  21635. * @returns current bounding info (or mesh's one if the submesh is global)
  21636. */
  21637. getBoundingInfo(): BoundingInfo;
  21638. /**
  21639. * Sets the submesh BoundingInfo
  21640. * @param boundingInfo defines the new bounding info to use
  21641. * @returns the SubMesh
  21642. */
  21643. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21644. /**
  21645. * Returns the mesh of the current submesh
  21646. * @return the parent mesh
  21647. */
  21648. getMesh(): AbstractMesh;
  21649. /**
  21650. * Returns the rendering mesh of the submesh
  21651. * @returns the rendering mesh (could be different from parent mesh)
  21652. */
  21653. getRenderingMesh(): Mesh;
  21654. /**
  21655. * Returns the submesh material
  21656. * @returns null or the current material
  21657. */
  21658. getMaterial(): Nullable<Material>;
  21659. /**
  21660. * Sets a new updated BoundingInfo object to the submesh
  21661. * @param data defines an optional position array to use to determine the bounding info
  21662. * @returns the SubMesh
  21663. */
  21664. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21665. /** @hidden */
  21666. _checkCollision(collider: Collider): boolean;
  21667. /**
  21668. * Updates the submesh BoundingInfo
  21669. * @param world defines the world matrix to use to update the bounding info
  21670. * @returns the submesh
  21671. */
  21672. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21673. /**
  21674. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21675. * @param frustumPlanes defines the frustum planes
  21676. * @returns true if the submesh is intersecting with the frustum
  21677. */
  21678. isInFrustum(frustumPlanes: Plane[]): boolean;
  21679. /**
  21680. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21681. * @param frustumPlanes defines the frustum planes
  21682. * @returns true if the submesh is inside the frustum
  21683. */
  21684. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21685. /**
  21686. * Renders the submesh
  21687. * @param enableAlphaMode defines if alpha needs to be used
  21688. * @returns the submesh
  21689. */
  21690. render(enableAlphaMode: boolean): SubMesh;
  21691. /**
  21692. * @hidden
  21693. */
  21694. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21695. /**
  21696. * Checks if the submesh intersects with a ray
  21697. * @param ray defines the ray to test
  21698. * @returns true is the passed ray intersects the submesh bounding box
  21699. */
  21700. canIntersects(ray: Ray): boolean;
  21701. /**
  21702. * Intersects current submesh with a ray
  21703. * @param ray defines the ray to test
  21704. * @param positions defines mesh's positions array
  21705. * @param indices defines mesh's indices array
  21706. * @param fastCheck defines if only bounding info should be used
  21707. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21708. * @returns intersection info or null if no intersection
  21709. */
  21710. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21711. /** @hidden */
  21712. private _intersectLines;
  21713. /** @hidden */
  21714. private _intersectUnIndexedLines;
  21715. /** @hidden */
  21716. private _intersectTriangles;
  21717. /** @hidden */
  21718. private _intersectUnIndexedTriangles;
  21719. /** @hidden */
  21720. _rebuild(): void;
  21721. /**
  21722. * Creates a new submesh from the passed mesh
  21723. * @param newMesh defines the new hosting mesh
  21724. * @param newRenderingMesh defines an optional rendering mesh
  21725. * @returns the new submesh
  21726. */
  21727. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21728. /**
  21729. * Release associated resources
  21730. */
  21731. dispose(): void;
  21732. /**
  21733. * Gets the class name
  21734. * @returns the string "SubMesh".
  21735. */
  21736. getClassName(): string;
  21737. /**
  21738. * Creates a new submesh from indices data
  21739. * @param materialIndex the index of the main mesh material
  21740. * @param startIndex the index where to start the copy in the mesh indices array
  21741. * @param indexCount the number of indices to copy then from the startIndex
  21742. * @param mesh the main mesh to create the submesh from
  21743. * @param renderingMesh the optional rendering mesh
  21744. * @returns a new submesh
  21745. */
  21746. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21747. }
  21748. }
  21749. declare module BABYLON {
  21750. /**
  21751. * Class used to represent data loading progression
  21752. */
  21753. export class SceneLoaderFlags {
  21754. private static _ForceFullSceneLoadingForIncremental;
  21755. private static _ShowLoadingScreen;
  21756. private static _CleanBoneMatrixWeights;
  21757. private static _loggingLevel;
  21758. /**
  21759. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21760. */
  21761. static get ForceFullSceneLoadingForIncremental(): boolean;
  21762. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21763. /**
  21764. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21765. */
  21766. static get ShowLoadingScreen(): boolean;
  21767. static set ShowLoadingScreen(value: boolean);
  21768. /**
  21769. * Defines the current logging level (while loading the scene)
  21770. * @ignorenaming
  21771. */
  21772. static get loggingLevel(): number;
  21773. static set loggingLevel(value: number);
  21774. /**
  21775. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21776. */
  21777. static get CleanBoneMatrixWeights(): boolean;
  21778. static set CleanBoneMatrixWeights(value: boolean);
  21779. }
  21780. }
  21781. declare module BABYLON {
  21782. /**
  21783. * Class used to store geometry data (vertex buffers + index buffer)
  21784. */
  21785. export class Geometry implements IGetSetVerticesData {
  21786. /**
  21787. * Gets or sets the ID of the geometry
  21788. */
  21789. id: string;
  21790. /**
  21791. * Gets or sets the unique ID of the geometry
  21792. */
  21793. uniqueId: number;
  21794. /**
  21795. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21796. */
  21797. delayLoadState: number;
  21798. /**
  21799. * Gets the file containing the data to load when running in delay load state
  21800. */
  21801. delayLoadingFile: Nullable<string>;
  21802. /**
  21803. * Callback called when the geometry is updated
  21804. */
  21805. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21806. private _scene;
  21807. private _engine;
  21808. private _meshes;
  21809. private _totalVertices;
  21810. /** @hidden */
  21811. _indices: IndicesArray;
  21812. /** @hidden */
  21813. _vertexBuffers: {
  21814. [key: string]: VertexBuffer;
  21815. };
  21816. private _isDisposed;
  21817. private _extend;
  21818. private _boundingBias;
  21819. /** @hidden */
  21820. _delayInfo: Array<string>;
  21821. private _indexBuffer;
  21822. private _indexBufferIsUpdatable;
  21823. /** @hidden */
  21824. _boundingInfo: Nullable<BoundingInfo>;
  21825. /** @hidden */
  21826. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21827. /** @hidden */
  21828. _softwareSkinningFrameId: number;
  21829. private _vertexArrayObjects;
  21830. private _updatable;
  21831. /** @hidden */
  21832. _positions: Nullable<Vector3[]>;
  21833. /**
  21834. * 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
  21835. */
  21836. get boundingBias(): Vector2;
  21837. /**
  21838. * 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
  21839. */
  21840. set boundingBias(value: Vector2);
  21841. /**
  21842. * Static function used to attach a new empty geometry to a mesh
  21843. * @param mesh defines the mesh to attach the geometry to
  21844. * @returns the new Geometry
  21845. */
  21846. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21847. /**
  21848. * Creates a new geometry
  21849. * @param id defines the unique ID
  21850. * @param scene defines the hosting scene
  21851. * @param vertexData defines the VertexData used to get geometry data
  21852. * @param updatable defines if geometry must be updatable (false by default)
  21853. * @param mesh defines the mesh that will be associated with the geometry
  21854. */
  21855. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21856. /**
  21857. * Gets the current extend of the geometry
  21858. */
  21859. get extend(): {
  21860. minimum: Vector3;
  21861. maximum: Vector3;
  21862. };
  21863. /**
  21864. * Gets the hosting scene
  21865. * @returns the hosting Scene
  21866. */
  21867. getScene(): Scene;
  21868. /**
  21869. * Gets the hosting engine
  21870. * @returns the hosting Engine
  21871. */
  21872. getEngine(): Engine;
  21873. /**
  21874. * Defines if the geometry is ready to use
  21875. * @returns true if the geometry is ready to be used
  21876. */
  21877. isReady(): boolean;
  21878. /**
  21879. * Gets a value indicating that the geometry should not be serialized
  21880. */
  21881. get doNotSerialize(): boolean;
  21882. /** @hidden */
  21883. _rebuild(): void;
  21884. /**
  21885. * Affects all geometry data in one call
  21886. * @param vertexData defines the geometry data
  21887. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21888. */
  21889. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21890. /**
  21891. * Set specific vertex data
  21892. * @param kind defines the data kind (Position, normal, etc...)
  21893. * @param data defines the vertex data to use
  21894. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21895. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21896. */
  21897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21898. /**
  21899. * Removes a specific vertex data
  21900. * @param kind defines the data kind (Position, normal, etc...)
  21901. */
  21902. removeVerticesData(kind: string): void;
  21903. /**
  21904. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21905. * @param buffer defines the vertex buffer to use
  21906. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21907. */
  21908. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21909. /**
  21910. * Update a specific vertex buffer
  21911. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21912. * It will do nothing if the buffer is not updatable
  21913. * @param kind defines the data kind (Position, normal, etc...)
  21914. * @param data defines the data to use
  21915. * @param offset defines the offset in the target buffer where to store the data
  21916. * @param useBytes set to true if the offset is in bytes
  21917. */
  21918. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21919. /**
  21920. * Update a specific vertex buffer
  21921. * This function will create a new buffer if the current one is not updatable
  21922. * @param kind defines the data kind (Position, normal, etc...)
  21923. * @param data defines the data to use
  21924. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21925. */
  21926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21927. private _updateBoundingInfo;
  21928. /** @hidden */
  21929. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21930. /**
  21931. * Gets total number of vertices
  21932. * @returns the total number of vertices
  21933. */
  21934. getTotalVertices(): number;
  21935. /**
  21936. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21937. * @param kind defines the data kind (Position, normal, etc...)
  21938. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21940. * @returns a float array containing vertex data
  21941. */
  21942. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21943. /**
  21944. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21945. * @param kind defines the data kind (Position, normal, etc...)
  21946. * @returns true if the vertex buffer with the specified kind is updatable
  21947. */
  21948. isVertexBufferUpdatable(kind: string): boolean;
  21949. /**
  21950. * Gets a specific vertex buffer
  21951. * @param kind defines the data kind (Position, normal, etc...)
  21952. * @returns a VertexBuffer
  21953. */
  21954. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21955. /**
  21956. * Returns all vertex buffers
  21957. * @return an object holding all vertex buffers indexed by kind
  21958. */
  21959. getVertexBuffers(): Nullable<{
  21960. [key: string]: VertexBuffer;
  21961. }>;
  21962. /**
  21963. * Gets a boolean indicating if specific vertex buffer is present
  21964. * @param kind defines the data kind (Position, normal, etc...)
  21965. * @returns true if data is present
  21966. */
  21967. isVerticesDataPresent(kind: string): boolean;
  21968. /**
  21969. * Gets a list of all attached data kinds (Position, normal, etc...)
  21970. * @returns a list of string containing all kinds
  21971. */
  21972. getVerticesDataKinds(): string[];
  21973. /**
  21974. * Update index buffer
  21975. * @param indices defines the indices to store in the index buffer
  21976. * @param offset defines the offset in the target buffer where to store the data
  21977. * @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)
  21978. */
  21979. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21980. /**
  21981. * Creates a new index buffer
  21982. * @param indices defines the indices to store in the index buffer
  21983. * @param totalVertices defines the total number of vertices (could be null)
  21984. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21985. */
  21986. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21987. /**
  21988. * Return the total number of indices
  21989. * @returns the total number of indices
  21990. */
  21991. getTotalIndices(): number;
  21992. /**
  21993. * Gets the index buffer array
  21994. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21996. * @returns the index buffer array
  21997. */
  21998. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21999. /**
  22000. * Gets the index buffer
  22001. * @return the index buffer
  22002. */
  22003. getIndexBuffer(): Nullable<DataBuffer>;
  22004. /** @hidden */
  22005. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22006. /**
  22007. * Release the associated resources for a specific mesh
  22008. * @param mesh defines the source mesh
  22009. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22010. */
  22011. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22012. /**
  22013. * Apply current geometry to a given mesh
  22014. * @param mesh defines the mesh to apply geometry to
  22015. */
  22016. applyToMesh(mesh: Mesh): void;
  22017. private _updateExtend;
  22018. private _applyToMesh;
  22019. private notifyUpdate;
  22020. /**
  22021. * Load the geometry if it was flagged as delay loaded
  22022. * @param scene defines the hosting scene
  22023. * @param onLoaded defines a callback called when the geometry is loaded
  22024. */
  22025. load(scene: Scene, onLoaded?: () => void): void;
  22026. private _queueLoad;
  22027. /**
  22028. * Invert the geometry to move from a right handed system to a left handed one.
  22029. */
  22030. toLeftHanded(): void;
  22031. /** @hidden */
  22032. _resetPointsArrayCache(): void;
  22033. /** @hidden */
  22034. _generatePointsArray(): boolean;
  22035. /**
  22036. * Gets a value indicating if the geometry is disposed
  22037. * @returns true if the geometry was disposed
  22038. */
  22039. isDisposed(): boolean;
  22040. private _disposeVertexArrayObjects;
  22041. /**
  22042. * Free all associated resources
  22043. */
  22044. dispose(): void;
  22045. /**
  22046. * Clone the current geometry into a new geometry
  22047. * @param id defines the unique ID of the new geometry
  22048. * @returns a new geometry object
  22049. */
  22050. copy(id: string): Geometry;
  22051. /**
  22052. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22053. * @return a JSON representation of the current geometry data (without the vertices data)
  22054. */
  22055. serialize(): any;
  22056. private toNumberArray;
  22057. /**
  22058. * Serialize all vertices data into a JSON oject
  22059. * @returns a JSON representation of the current geometry data
  22060. */
  22061. serializeVerticeData(): any;
  22062. /**
  22063. * Extracts a clone of a mesh geometry
  22064. * @param mesh defines the source mesh
  22065. * @param id defines the unique ID of the new geometry object
  22066. * @returns the new geometry object
  22067. */
  22068. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22069. /**
  22070. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22071. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22072. * Be aware Math.random() could cause collisions, but:
  22073. * "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"
  22074. * @returns a string containing a new GUID
  22075. */
  22076. static RandomId(): string;
  22077. /** @hidden */
  22078. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22079. private static _CleanMatricesWeights;
  22080. /**
  22081. * Create a new geometry from persisted data (Using .babylon file format)
  22082. * @param parsedVertexData defines the persisted data
  22083. * @param scene defines the hosting scene
  22084. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22085. * @returns the new geometry object
  22086. */
  22087. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22088. }
  22089. }
  22090. declare module BABYLON {
  22091. /**
  22092. * Define an interface for all classes that will get and set the data on vertices
  22093. */
  22094. export interface IGetSetVerticesData {
  22095. /**
  22096. * Gets a boolean indicating if specific vertex data is present
  22097. * @param kind defines the vertex data kind to use
  22098. * @returns true is data kind is present
  22099. */
  22100. isVerticesDataPresent(kind: string): boolean;
  22101. /**
  22102. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22103. * @param kind defines the data kind (Position, normal, etc...)
  22104. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22105. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22106. * @returns a float array containing vertex data
  22107. */
  22108. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22109. /**
  22110. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22111. * @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.
  22112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22113. * @returns the indices array or an empty array if the mesh has no geometry
  22114. */
  22115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22116. /**
  22117. * Set specific vertex data
  22118. * @param kind defines the data kind (Position, normal, etc...)
  22119. * @param data defines the vertex data to use
  22120. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22121. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22122. */
  22123. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22124. /**
  22125. * Update a specific associated vertex buffer
  22126. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22127. * - VertexBuffer.PositionKind
  22128. * - VertexBuffer.UVKind
  22129. * - VertexBuffer.UV2Kind
  22130. * - VertexBuffer.UV3Kind
  22131. * - VertexBuffer.UV4Kind
  22132. * - VertexBuffer.UV5Kind
  22133. * - VertexBuffer.UV6Kind
  22134. * - VertexBuffer.ColorKind
  22135. * - VertexBuffer.MatricesIndicesKind
  22136. * - VertexBuffer.MatricesIndicesExtraKind
  22137. * - VertexBuffer.MatricesWeightsKind
  22138. * - VertexBuffer.MatricesWeightsExtraKind
  22139. * @param data defines the data source
  22140. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22141. * @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)
  22142. */
  22143. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22144. /**
  22145. * Creates a new index buffer
  22146. * @param indices defines the indices to store in the index buffer
  22147. * @param totalVertices defines the total number of vertices (could be null)
  22148. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22149. */
  22150. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22151. }
  22152. /**
  22153. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22154. */
  22155. export class VertexData {
  22156. /**
  22157. * Mesh side orientation : usually the external or front surface
  22158. */
  22159. static readonly FRONTSIDE: number;
  22160. /**
  22161. * Mesh side orientation : usually the internal or back surface
  22162. */
  22163. static readonly BACKSIDE: number;
  22164. /**
  22165. * Mesh side orientation : both internal and external or front and back surfaces
  22166. */
  22167. static readonly DOUBLESIDE: number;
  22168. /**
  22169. * Mesh side orientation : by default, `FRONTSIDE`
  22170. */
  22171. static readonly DEFAULTSIDE: number;
  22172. /**
  22173. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22174. */
  22175. positions: Nullable<FloatArray>;
  22176. /**
  22177. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22178. */
  22179. normals: Nullable<FloatArray>;
  22180. /**
  22181. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22182. */
  22183. tangents: Nullable<FloatArray>;
  22184. /**
  22185. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22186. */
  22187. uvs: Nullable<FloatArray>;
  22188. /**
  22189. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22190. */
  22191. uvs2: Nullable<FloatArray>;
  22192. /**
  22193. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22194. */
  22195. uvs3: Nullable<FloatArray>;
  22196. /**
  22197. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22198. */
  22199. uvs4: Nullable<FloatArray>;
  22200. /**
  22201. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22202. */
  22203. uvs5: Nullable<FloatArray>;
  22204. /**
  22205. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22206. */
  22207. uvs6: Nullable<FloatArray>;
  22208. /**
  22209. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22210. */
  22211. colors: Nullable<FloatArray>;
  22212. /**
  22213. * 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).
  22214. */
  22215. matricesIndices: Nullable<FloatArray>;
  22216. /**
  22217. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22218. */
  22219. matricesWeights: Nullable<FloatArray>;
  22220. /**
  22221. * An array extending the number of possible indices
  22222. */
  22223. matricesIndicesExtra: Nullable<FloatArray>;
  22224. /**
  22225. * An array extending the number of possible weights when the number of indices is extended
  22226. */
  22227. matricesWeightsExtra: Nullable<FloatArray>;
  22228. /**
  22229. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22230. */
  22231. indices: Nullable<IndicesArray>;
  22232. /**
  22233. * Uses the passed data array to set the set the values for the specified kind of data
  22234. * @param data a linear array of floating numbers
  22235. * @param kind the type of data that is being set, eg positions, colors etc
  22236. */
  22237. set(data: FloatArray, kind: string): void;
  22238. /**
  22239. * Associates the vertexData to the passed Mesh.
  22240. * Sets it as updatable or not (default `false`)
  22241. * @param mesh the mesh the vertexData is applied to
  22242. * @param updatable when used and having the value true allows new data to update the vertexData
  22243. * @returns the VertexData
  22244. */
  22245. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22246. /**
  22247. * Associates the vertexData to the passed Geometry.
  22248. * Sets it as updatable or not (default `false`)
  22249. * @param geometry the geometry the vertexData is applied to
  22250. * @param updatable when used and having the value true allows new data to update the vertexData
  22251. * @returns VertexData
  22252. */
  22253. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22254. /**
  22255. * Updates the associated mesh
  22256. * @param mesh the mesh to be updated
  22257. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22258. * @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
  22259. * @returns VertexData
  22260. */
  22261. updateMesh(mesh: Mesh): VertexData;
  22262. /**
  22263. * Updates the associated geometry
  22264. * @param geometry the geometry to be updated
  22265. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22266. * @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
  22267. * @returns VertexData.
  22268. */
  22269. updateGeometry(geometry: Geometry): VertexData;
  22270. private _applyTo;
  22271. private _update;
  22272. /**
  22273. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22274. * @param matrix the transforming matrix
  22275. * @returns the VertexData
  22276. */
  22277. transform(matrix: Matrix): VertexData;
  22278. /**
  22279. * Merges the passed VertexData into the current one
  22280. * @param other the VertexData to be merged into the current one
  22281. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22282. * @returns the modified VertexData
  22283. */
  22284. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22285. private _mergeElement;
  22286. private _validate;
  22287. /**
  22288. * Serializes the VertexData
  22289. * @returns a serialized object
  22290. */
  22291. serialize(): any;
  22292. /**
  22293. * Extracts the vertexData from a mesh
  22294. * @param mesh the mesh from which to extract the VertexData
  22295. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22296. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22297. * @returns the object VertexData associated to the passed mesh
  22298. */
  22299. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22300. /**
  22301. * Extracts the vertexData from the geometry
  22302. * @param geometry the geometry from which to extract the VertexData
  22303. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22304. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22305. * @returns the object VertexData associated to the passed mesh
  22306. */
  22307. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22308. private static _ExtractFrom;
  22309. /**
  22310. * Creates the VertexData for a Ribbon
  22311. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22312. * * pathArray array of paths, each of which an array of successive Vector3
  22313. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22314. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22315. * * 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
  22316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22317. * * 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)
  22318. * * 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)
  22319. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22320. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22321. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22322. * @returns the VertexData of the ribbon
  22323. */
  22324. static CreateRibbon(options: {
  22325. pathArray: Vector3[][];
  22326. closeArray?: boolean;
  22327. closePath?: boolean;
  22328. offset?: number;
  22329. sideOrientation?: number;
  22330. frontUVs?: Vector4;
  22331. backUVs?: Vector4;
  22332. invertUV?: boolean;
  22333. uvs?: Vector2[];
  22334. colors?: Color4[];
  22335. }): VertexData;
  22336. /**
  22337. * Creates the VertexData for a box
  22338. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22339. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22340. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22341. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22342. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22343. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22344. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreateBox(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. depth?: number;
  22355. faceUV?: Vector4[];
  22356. faceColors?: Color4[];
  22357. sideOrientation?: number;
  22358. frontUVs?: Vector4;
  22359. backUVs?: Vector4;
  22360. }): VertexData;
  22361. /**
  22362. * Creates the VertexData for a tiled box
  22363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22364. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22365. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22366. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22368. * @returns the VertexData of the box
  22369. */
  22370. static CreateTiledBox(options: {
  22371. pattern?: number;
  22372. width?: number;
  22373. height?: number;
  22374. depth?: number;
  22375. tileSize?: number;
  22376. tileWidth?: number;
  22377. tileHeight?: number;
  22378. alignHorizontal?: number;
  22379. alignVertical?: number;
  22380. faceUV?: Vector4[];
  22381. faceColors?: Color4[];
  22382. sideOrientation?: number;
  22383. }): VertexData;
  22384. /**
  22385. * Creates the VertexData for a tiled plane
  22386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22387. * * pattern a limited pattern arrangement depending on the number
  22388. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22389. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22390. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22392. * * 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)
  22393. * * 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)
  22394. * @returns the VertexData of the tiled plane
  22395. */
  22396. static CreateTiledPlane(options: {
  22397. pattern?: number;
  22398. tileSize?: number;
  22399. tileWidth?: number;
  22400. tileHeight?: number;
  22401. size?: number;
  22402. width?: number;
  22403. height?: number;
  22404. alignHorizontal?: number;
  22405. alignVertical?: number;
  22406. sideOrientation?: number;
  22407. frontUVs?: Vector4;
  22408. backUVs?: Vector4;
  22409. }): VertexData;
  22410. /**
  22411. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22412. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22413. * * segments sets the number of horizontal strips optional, default 32
  22414. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22415. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22416. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22417. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22418. * * 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
  22419. * * 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
  22420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * * 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)
  22422. * * 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)
  22423. * @returns the VertexData of the ellipsoid
  22424. */
  22425. static CreateSphere(options: {
  22426. segments?: number;
  22427. diameter?: number;
  22428. diameterX?: number;
  22429. diameterY?: number;
  22430. diameterZ?: number;
  22431. arc?: number;
  22432. slice?: number;
  22433. sideOrientation?: number;
  22434. frontUVs?: Vector4;
  22435. backUVs?: Vector4;
  22436. }): VertexData;
  22437. /**
  22438. * Creates the VertexData for a cylinder, cone or prism
  22439. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22440. * * height sets the height (y direction) of the cylinder, optional, default 2
  22441. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22442. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22443. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22444. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22445. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22446. * * 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
  22447. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22448. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22449. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22450. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22452. * * 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)
  22453. * * 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)
  22454. * @returns the VertexData of the cylinder, cone or prism
  22455. */
  22456. static CreateCylinder(options: {
  22457. height?: number;
  22458. diameterTop?: number;
  22459. diameterBottom?: number;
  22460. diameter?: number;
  22461. tessellation?: number;
  22462. subdivisions?: number;
  22463. arc?: number;
  22464. faceColors?: Color4[];
  22465. faceUV?: Vector4[];
  22466. hasRings?: boolean;
  22467. enclose?: boolean;
  22468. sideOrientation?: number;
  22469. frontUVs?: Vector4;
  22470. backUVs?: Vector4;
  22471. }): VertexData;
  22472. /**
  22473. * Creates the VertexData for a torus
  22474. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22475. * * diameter the diameter of the torus, optional default 1
  22476. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22477. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22479. * * 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)
  22480. * * 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)
  22481. * @returns the VertexData of the torus
  22482. */
  22483. static CreateTorus(options: {
  22484. diameter?: number;
  22485. thickness?: number;
  22486. tessellation?: number;
  22487. sideOrientation?: number;
  22488. frontUVs?: Vector4;
  22489. backUVs?: Vector4;
  22490. }): VertexData;
  22491. /**
  22492. * Creates the VertexData of the LineSystem
  22493. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22494. * - lines an array of lines, each line being an array of successive Vector3
  22495. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22496. * @returns the VertexData of the LineSystem
  22497. */
  22498. static CreateLineSystem(options: {
  22499. lines: Vector3[][];
  22500. colors?: Nullable<Color4[][]>;
  22501. }): VertexData;
  22502. /**
  22503. * Create the VertexData for a DashedLines
  22504. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22505. * - points an array successive Vector3
  22506. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22507. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22508. * - dashNb the intended total number of dashes, optional, default 200
  22509. * @returns the VertexData for the DashedLines
  22510. */
  22511. static CreateDashedLines(options: {
  22512. points: Vector3[];
  22513. dashSize?: number;
  22514. gapSize?: number;
  22515. dashNb?: number;
  22516. }): VertexData;
  22517. /**
  22518. * Creates the VertexData for a Ground
  22519. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22520. * - width the width (x direction) of the ground, optional, default 1
  22521. * - height the height (z direction) of the ground, optional, default 1
  22522. * - subdivisions the number of subdivisions per side, optional, default 1
  22523. * @returns the VertexData of the Ground
  22524. */
  22525. static CreateGround(options: {
  22526. width?: number;
  22527. height?: number;
  22528. subdivisions?: number;
  22529. subdivisionsX?: number;
  22530. subdivisionsY?: number;
  22531. }): VertexData;
  22532. /**
  22533. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22534. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22535. * * xmin the ground minimum X coordinate, optional, default -1
  22536. * * zmin the ground minimum Z coordinate, optional, default -1
  22537. * * xmax the ground maximum X coordinate, optional, default 1
  22538. * * zmax the ground maximum Z coordinate, optional, default 1
  22539. * * 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}
  22540. * * 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}
  22541. * @returns the VertexData of the TiledGround
  22542. */
  22543. static CreateTiledGround(options: {
  22544. xmin: number;
  22545. zmin: number;
  22546. xmax: number;
  22547. zmax: number;
  22548. subdivisions?: {
  22549. w: number;
  22550. h: number;
  22551. };
  22552. precision?: {
  22553. w: number;
  22554. h: number;
  22555. };
  22556. }): VertexData;
  22557. /**
  22558. * Creates the VertexData of the Ground designed from a heightmap
  22559. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22560. * * width the width (x direction) of the ground
  22561. * * height the height (z direction) of the ground
  22562. * * subdivisions the number of subdivisions per side
  22563. * * minHeight the minimum altitude on the ground, optional, default 0
  22564. * * maxHeight the maximum altitude on the ground, optional default 1
  22565. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22566. * * buffer the array holding the image color data
  22567. * * bufferWidth the width of image
  22568. * * bufferHeight the height of image
  22569. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22570. * @returns the VertexData of the Ground designed from a heightmap
  22571. */
  22572. static CreateGroundFromHeightMap(options: {
  22573. width: number;
  22574. height: number;
  22575. subdivisions: number;
  22576. minHeight: number;
  22577. maxHeight: number;
  22578. colorFilter: Color3;
  22579. buffer: Uint8Array;
  22580. bufferWidth: number;
  22581. bufferHeight: number;
  22582. alphaFilter: number;
  22583. }): VertexData;
  22584. /**
  22585. * Creates the VertexData for a Plane
  22586. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22587. * * size sets the width and height of the plane to the value of size, optional default 1
  22588. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22589. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22591. * * 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)
  22592. * * 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)
  22593. * @returns the VertexData of the box
  22594. */
  22595. static CreatePlane(options: {
  22596. size?: number;
  22597. width?: number;
  22598. height?: number;
  22599. sideOrientation?: number;
  22600. frontUVs?: Vector4;
  22601. backUVs?: Vector4;
  22602. }): VertexData;
  22603. /**
  22604. * Creates the VertexData of the Disc or regular Polygon
  22605. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22606. * * radius the radius of the disc, optional default 0.5
  22607. * * tessellation the number of polygon sides, optional, default 64
  22608. * * 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
  22609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22610. * * 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)
  22611. * * 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)
  22612. * @returns the VertexData of the box
  22613. */
  22614. static CreateDisc(options: {
  22615. radius?: number;
  22616. tessellation?: number;
  22617. arc?: number;
  22618. sideOrientation?: number;
  22619. frontUVs?: Vector4;
  22620. backUVs?: Vector4;
  22621. }): VertexData;
  22622. /**
  22623. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22624. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22625. * @param polygon a mesh built from polygonTriangulation.build()
  22626. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22627. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22628. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22629. * @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)
  22630. * @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)
  22631. * @returns the VertexData of the Polygon
  22632. */
  22633. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22634. /**
  22635. * Creates the VertexData of the IcoSphere
  22636. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22637. * * radius the radius of the IcoSphere, optional default 1
  22638. * * radiusX allows stretching in the x direction, optional, default radius
  22639. * * radiusY allows stretching in the y direction, optional, default radius
  22640. * * radiusZ allows stretching in the z direction, optional, default radius
  22641. * * flat when true creates a flat shaded mesh, optional, default true
  22642. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22644. * * 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)
  22645. * * 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)
  22646. * @returns the VertexData of the IcoSphere
  22647. */
  22648. static CreateIcoSphere(options: {
  22649. radius?: number;
  22650. radiusX?: number;
  22651. radiusY?: number;
  22652. radiusZ?: number;
  22653. flat?: boolean;
  22654. subdivisions?: number;
  22655. sideOrientation?: number;
  22656. frontUVs?: Vector4;
  22657. backUVs?: Vector4;
  22658. }): VertexData;
  22659. /**
  22660. * Creates the VertexData for a Polyhedron
  22661. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22662. * * type provided types are:
  22663. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22664. * * 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)
  22665. * * size the size of the IcoSphere, optional default 1
  22666. * * sizeX allows stretching in the x direction, optional, default size
  22667. * * sizeY allows stretching in the y direction, optional, default size
  22668. * * sizeZ allows stretching in the z direction, optional, default size
  22669. * * 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
  22670. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22671. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22672. * * flat when true creates a flat shaded mesh, optional, default true
  22673. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22675. * * 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)
  22676. * * 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)
  22677. * @returns the VertexData of the Polyhedron
  22678. */
  22679. static CreatePolyhedron(options: {
  22680. type?: number;
  22681. size?: number;
  22682. sizeX?: number;
  22683. sizeY?: number;
  22684. sizeZ?: number;
  22685. custom?: any;
  22686. faceUV?: Vector4[];
  22687. faceColors?: Color4[];
  22688. flat?: boolean;
  22689. sideOrientation?: number;
  22690. frontUVs?: Vector4;
  22691. backUVs?: Vector4;
  22692. }): VertexData;
  22693. /**
  22694. * Creates the VertexData for a TorusKnot
  22695. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22696. * * radius the radius of the torus knot, optional, default 2
  22697. * * tube the thickness of the tube, optional, default 0.5
  22698. * * radialSegments the number of sides on each tube segments, optional, default 32
  22699. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22700. * * p the number of windings around the z axis, optional, default 2
  22701. * * q the number of windings around the x axis, optional, default 3
  22702. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22703. * * 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)
  22704. * * 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)
  22705. * @returns the VertexData of the Torus Knot
  22706. */
  22707. static CreateTorusKnot(options: {
  22708. radius?: number;
  22709. tube?: number;
  22710. radialSegments?: number;
  22711. tubularSegments?: number;
  22712. p?: number;
  22713. q?: number;
  22714. sideOrientation?: number;
  22715. frontUVs?: Vector4;
  22716. backUVs?: Vector4;
  22717. }): VertexData;
  22718. /**
  22719. * Compute normals for given positions and indices
  22720. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22721. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22722. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22723. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22724. * * facetNormals : optional array of facet normals (vector3)
  22725. * * facetPositions : optional array of facet positions (vector3)
  22726. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22727. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22728. * * bInfo : optional bounding info, required for facetPartitioning computation
  22729. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22730. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22731. * * useRightHandedSystem: optional boolean to for right handed system computation
  22732. * * depthSort : optional boolean to enable the facet depth sort computation
  22733. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22734. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22735. */
  22736. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22737. facetNormals?: any;
  22738. facetPositions?: any;
  22739. facetPartitioning?: any;
  22740. ratio?: number;
  22741. bInfo?: any;
  22742. bbSize?: Vector3;
  22743. subDiv?: any;
  22744. useRightHandedSystem?: boolean;
  22745. depthSort?: boolean;
  22746. distanceTo?: Vector3;
  22747. depthSortedFacets?: any;
  22748. }): void;
  22749. /** @hidden */
  22750. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22751. /**
  22752. * Applies VertexData created from the imported parameters to the geometry
  22753. * @param parsedVertexData the parsed data from an imported file
  22754. * @param geometry the geometry to apply the VertexData to
  22755. */
  22756. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22757. }
  22758. }
  22759. declare module BABYLON {
  22760. /**
  22761. * Defines a target to use with MorphTargetManager
  22762. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22763. */
  22764. export class MorphTarget implements IAnimatable {
  22765. /** defines the name of the target */
  22766. name: string;
  22767. /**
  22768. * Gets or sets the list of animations
  22769. */
  22770. animations: Animation[];
  22771. private _scene;
  22772. private _positions;
  22773. private _normals;
  22774. private _tangents;
  22775. private _uvs;
  22776. private _influence;
  22777. private _uniqueId;
  22778. /**
  22779. * Observable raised when the influence changes
  22780. */
  22781. onInfluenceChanged: Observable<boolean>;
  22782. /** @hidden */
  22783. _onDataLayoutChanged: Observable<void>;
  22784. /**
  22785. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22786. */
  22787. get influence(): number;
  22788. set influence(influence: number);
  22789. /**
  22790. * Gets or sets the id of the morph Target
  22791. */
  22792. id: string;
  22793. private _animationPropertiesOverride;
  22794. /**
  22795. * Gets or sets the animation properties override
  22796. */
  22797. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22798. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22799. /**
  22800. * Creates a new MorphTarget
  22801. * @param name defines the name of the target
  22802. * @param influence defines the influence to use
  22803. * @param scene defines the scene the morphtarget belongs to
  22804. */
  22805. constructor(
  22806. /** defines the name of the target */
  22807. name: string, influence?: number, scene?: Nullable<Scene>);
  22808. /**
  22809. * Gets the unique ID of this manager
  22810. */
  22811. get uniqueId(): number;
  22812. /**
  22813. * Gets a boolean defining if the target contains position data
  22814. */
  22815. get hasPositions(): boolean;
  22816. /**
  22817. * Gets a boolean defining if the target contains normal data
  22818. */
  22819. get hasNormals(): boolean;
  22820. /**
  22821. * Gets a boolean defining if the target contains tangent data
  22822. */
  22823. get hasTangents(): boolean;
  22824. /**
  22825. * Gets a boolean defining if the target contains texture coordinates data
  22826. */
  22827. get hasUVs(): boolean;
  22828. /**
  22829. * Affects position data to this target
  22830. * @param data defines the position data to use
  22831. */
  22832. setPositions(data: Nullable<FloatArray>): void;
  22833. /**
  22834. * Gets the position data stored in this target
  22835. * @returns a FloatArray containing the position data (or null if not present)
  22836. */
  22837. getPositions(): Nullable<FloatArray>;
  22838. /**
  22839. * Affects normal data to this target
  22840. * @param data defines the normal data to use
  22841. */
  22842. setNormals(data: Nullable<FloatArray>): void;
  22843. /**
  22844. * Gets the normal data stored in this target
  22845. * @returns a FloatArray containing the normal data (or null if not present)
  22846. */
  22847. getNormals(): Nullable<FloatArray>;
  22848. /**
  22849. * Affects tangent data to this target
  22850. * @param data defines the tangent data to use
  22851. */
  22852. setTangents(data: Nullable<FloatArray>): void;
  22853. /**
  22854. * Gets the tangent data stored in this target
  22855. * @returns a FloatArray containing the tangent data (or null if not present)
  22856. */
  22857. getTangents(): Nullable<FloatArray>;
  22858. /**
  22859. * Affects texture coordinates data to this target
  22860. * @param data defines the texture coordinates data to use
  22861. */
  22862. setUVs(data: Nullable<FloatArray>): void;
  22863. /**
  22864. * Gets the texture coordinates data stored in this target
  22865. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22866. */
  22867. getUVs(): Nullable<FloatArray>;
  22868. /**
  22869. * Clone the current target
  22870. * @returns a new MorphTarget
  22871. */
  22872. clone(): MorphTarget;
  22873. /**
  22874. * Serializes the current target into a Serialization object
  22875. * @returns the serialized object
  22876. */
  22877. serialize(): any;
  22878. /**
  22879. * Returns the string "MorphTarget"
  22880. * @returns "MorphTarget"
  22881. */
  22882. getClassName(): string;
  22883. /**
  22884. * Creates a new target from serialized data
  22885. * @param serializationObject defines the serialized data to use
  22886. * @returns a new MorphTarget
  22887. */
  22888. static Parse(serializationObject: any): MorphTarget;
  22889. /**
  22890. * Creates a MorphTarget from mesh data
  22891. * @param mesh defines the source mesh
  22892. * @param name defines the name to use for the new target
  22893. * @param influence defines the influence to attach to the target
  22894. * @returns a new MorphTarget
  22895. */
  22896. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22897. }
  22898. }
  22899. declare module BABYLON {
  22900. /**
  22901. * This class is used to deform meshes using morphing between different targets
  22902. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22903. */
  22904. export class MorphTargetManager {
  22905. private _targets;
  22906. private _targetInfluenceChangedObservers;
  22907. private _targetDataLayoutChangedObservers;
  22908. private _activeTargets;
  22909. private _scene;
  22910. private _influences;
  22911. private _supportsNormals;
  22912. private _supportsTangents;
  22913. private _supportsUVs;
  22914. private _vertexCount;
  22915. private _uniqueId;
  22916. private _tempInfluences;
  22917. /**
  22918. * Gets or sets a boolean indicating if normals must be morphed
  22919. */
  22920. enableNormalMorphing: boolean;
  22921. /**
  22922. * Gets or sets a boolean indicating if tangents must be morphed
  22923. */
  22924. enableTangentMorphing: boolean;
  22925. /**
  22926. * Gets or sets a boolean indicating if UV must be morphed
  22927. */
  22928. enableUVMorphing: boolean;
  22929. /**
  22930. * Creates a new MorphTargetManager
  22931. * @param scene defines the current scene
  22932. */
  22933. constructor(scene?: Nullable<Scene>);
  22934. /**
  22935. * Gets the unique ID of this manager
  22936. */
  22937. get uniqueId(): number;
  22938. /**
  22939. * Gets the number of vertices handled by this manager
  22940. */
  22941. get vertexCount(): number;
  22942. /**
  22943. * Gets a boolean indicating if this manager supports morphing of normals
  22944. */
  22945. get supportsNormals(): boolean;
  22946. /**
  22947. * Gets a boolean indicating if this manager supports morphing of tangents
  22948. */
  22949. get supportsTangents(): boolean;
  22950. /**
  22951. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22952. */
  22953. get supportsUVs(): boolean;
  22954. /**
  22955. * Gets the number of targets stored in this manager
  22956. */
  22957. get numTargets(): number;
  22958. /**
  22959. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22960. */
  22961. get numInfluencers(): number;
  22962. /**
  22963. * Gets the list of influences (one per target)
  22964. */
  22965. get influences(): Float32Array;
  22966. /**
  22967. * Gets the active target at specified index. An active target is a target with an influence > 0
  22968. * @param index defines the index to check
  22969. * @returns the requested target
  22970. */
  22971. getActiveTarget(index: number): MorphTarget;
  22972. /**
  22973. * Gets the target at specified index
  22974. * @param index defines the index to check
  22975. * @returns the requested target
  22976. */
  22977. getTarget(index: number): MorphTarget;
  22978. /**
  22979. * Add a new target to this manager
  22980. * @param target defines the target to add
  22981. */
  22982. addTarget(target: MorphTarget): void;
  22983. /**
  22984. * Removes a target from the manager
  22985. * @param target defines the target to remove
  22986. */
  22987. removeTarget(target: MorphTarget): void;
  22988. /**
  22989. * Clone the current manager
  22990. * @returns a new MorphTargetManager
  22991. */
  22992. clone(): MorphTargetManager;
  22993. /**
  22994. * Serializes the current manager into a Serialization object
  22995. * @returns the serialized object
  22996. */
  22997. serialize(): any;
  22998. private _syncActiveTargets;
  22999. /**
  23000. * Syncrhonize the targets with all the meshes using this morph target manager
  23001. */
  23002. synchronize(): void;
  23003. /**
  23004. * Creates a new MorphTargetManager from serialized data
  23005. * @param serializationObject defines the serialized data
  23006. * @param scene defines the hosting scene
  23007. * @returns the new MorphTargetManager
  23008. */
  23009. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23010. }
  23011. }
  23012. declare module BABYLON {
  23013. /**
  23014. * Class used to represent a specific level of detail of a mesh
  23015. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23016. */
  23017. export class MeshLODLevel {
  23018. /** Defines the distance where this level should start being displayed */
  23019. distance: number;
  23020. /** Defines the mesh to use to render this level */
  23021. mesh: Nullable<Mesh>;
  23022. /**
  23023. * Creates a new LOD level
  23024. * @param distance defines the distance where this level should star being displayed
  23025. * @param mesh defines the mesh to use to render this level
  23026. */
  23027. constructor(
  23028. /** Defines the distance where this level should start being displayed */
  23029. distance: number,
  23030. /** Defines the mesh to use to render this level */
  23031. mesh: Nullable<Mesh>);
  23032. }
  23033. }
  23034. declare module BABYLON {
  23035. /**
  23036. * Mesh representing the gorund
  23037. */
  23038. export class GroundMesh extends Mesh {
  23039. /** If octree should be generated */
  23040. generateOctree: boolean;
  23041. private _heightQuads;
  23042. /** @hidden */
  23043. _subdivisionsX: number;
  23044. /** @hidden */
  23045. _subdivisionsY: number;
  23046. /** @hidden */
  23047. _width: number;
  23048. /** @hidden */
  23049. _height: number;
  23050. /** @hidden */
  23051. _minX: number;
  23052. /** @hidden */
  23053. _maxX: number;
  23054. /** @hidden */
  23055. _minZ: number;
  23056. /** @hidden */
  23057. _maxZ: number;
  23058. constructor(name: string, scene: Scene);
  23059. /**
  23060. * "GroundMesh"
  23061. * @returns "GroundMesh"
  23062. */
  23063. getClassName(): string;
  23064. /**
  23065. * The minimum of x and y subdivisions
  23066. */
  23067. get subdivisions(): number;
  23068. /**
  23069. * X subdivisions
  23070. */
  23071. get subdivisionsX(): number;
  23072. /**
  23073. * Y subdivisions
  23074. */
  23075. get subdivisionsY(): number;
  23076. /**
  23077. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23078. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23079. * @param chunksCount the number of subdivisions for x and y
  23080. * @param octreeBlocksSize (Default: 32)
  23081. */
  23082. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23083. /**
  23084. * Returns a height (y) value in the Worl system :
  23085. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23086. * @param x x coordinate
  23087. * @param z z coordinate
  23088. * @returns the ground y position if (x, z) are outside the ground surface.
  23089. */
  23090. getHeightAtCoordinates(x: number, z: number): number;
  23091. /**
  23092. * Returns a normalized vector (Vector3) orthogonal to the ground
  23093. * at the ground coordinates (x, z) expressed in the World system.
  23094. * @param x x coordinate
  23095. * @param z z coordinate
  23096. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23097. */
  23098. getNormalAtCoordinates(x: number, z: number): Vector3;
  23099. /**
  23100. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23101. * at the ground coordinates (x, z) expressed in the World system.
  23102. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23103. * @param x x coordinate
  23104. * @param z z coordinate
  23105. * @param ref vector to store the result
  23106. * @returns the GroundMesh.
  23107. */
  23108. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23109. /**
  23110. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23111. * if the ground has been updated.
  23112. * This can be used in the render loop.
  23113. * @returns the GroundMesh.
  23114. */
  23115. updateCoordinateHeights(): GroundMesh;
  23116. private _getFacetAt;
  23117. private _initHeightQuads;
  23118. private _computeHeightQuads;
  23119. /**
  23120. * Serializes this ground mesh
  23121. * @param serializationObject object to write serialization to
  23122. */
  23123. serialize(serializationObject: any): void;
  23124. /**
  23125. * Parses a serialized ground mesh
  23126. * @param parsedMesh the serialized mesh
  23127. * @param scene the scene to create the ground mesh in
  23128. * @returns the created ground mesh
  23129. */
  23130. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23131. }
  23132. }
  23133. declare module BABYLON {
  23134. /**
  23135. * Interface for Physics-Joint data
  23136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23137. */
  23138. export interface PhysicsJointData {
  23139. /**
  23140. * The main pivot of the joint
  23141. */
  23142. mainPivot?: Vector3;
  23143. /**
  23144. * The connected pivot of the joint
  23145. */
  23146. connectedPivot?: Vector3;
  23147. /**
  23148. * The main axis of the joint
  23149. */
  23150. mainAxis?: Vector3;
  23151. /**
  23152. * The connected axis of the joint
  23153. */
  23154. connectedAxis?: Vector3;
  23155. /**
  23156. * The collision of the joint
  23157. */
  23158. collision?: boolean;
  23159. /**
  23160. * Native Oimo/Cannon/Energy data
  23161. */
  23162. nativeParams?: any;
  23163. }
  23164. /**
  23165. * This is a holder class for the physics joint created by the physics plugin
  23166. * It holds a set of functions to control the underlying joint
  23167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23168. */
  23169. export class PhysicsJoint {
  23170. /**
  23171. * The type of the physics joint
  23172. */
  23173. type: number;
  23174. /**
  23175. * The data for the physics joint
  23176. */
  23177. jointData: PhysicsJointData;
  23178. private _physicsJoint;
  23179. protected _physicsPlugin: IPhysicsEnginePlugin;
  23180. /**
  23181. * Initializes the physics joint
  23182. * @param type The type of the physics joint
  23183. * @param jointData The data for the physics joint
  23184. */
  23185. constructor(
  23186. /**
  23187. * The type of the physics joint
  23188. */
  23189. type: number,
  23190. /**
  23191. * The data for the physics joint
  23192. */
  23193. jointData: PhysicsJointData);
  23194. /**
  23195. * Gets the physics joint
  23196. */
  23197. get physicsJoint(): any;
  23198. /**
  23199. * Sets the physics joint
  23200. */
  23201. set physicsJoint(newJoint: any);
  23202. /**
  23203. * Sets the physics plugin
  23204. */
  23205. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23206. /**
  23207. * Execute a function that is physics-plugin specific.
  23208. * @param {Function} func the function that will be executed.
  23209. * It accepts two parameters: the physics world and the physics joint
  23210. */
  23211. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23212. /**
  23213. * Distance-Joint type
  23214. */
  23215. static DistanceJoint: number;
  23216. /**
  23217. * Hinge-Joint type
  23218. */
  23219. static HingeJoint: number;
  23220. /**
  23221. * Ball-and-Socket joint type
  23222. */
  23223. static BallAndSocketJoint: number;
  23224. /**
  23225. * Wheel-Joint type
  23226. */
  23227. static WheelJoint: number;
  23228. /**
  23229. * Slider-Joint type
  23230. */
  23231. static SliderJoint: number;
  23232. /**
  23233. * Prismatic-Joint type
  23234. */
  23235. static PrismaticJoint: number;
  23236. /**
  23237. * Universal-Joint type
  23238. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23239. */
  23240. static UniversalJoint: number;
  23241. /**
  23242. * Hinge-Joint 2 type
  23243. */
  23244. static Hinge2Joint: number;
  23245. /**
  23246. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23247. */
  23248. static PointToPointJoint: number;
  23249. /**
  23250. * Spring-Joint type
  23251. */
  23252. static SpringJoint: number;
  23253. /**
  23254. * Lock-Joint type
  23255. */
  23256. static LockJoint: number;
  23257. }
  23258. /**
  23259. * A class representing a physics distance joint
  23260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23261. */
  23262. export class DistanceJoint extends PhysicsJoint {
  23263. /**
  23264. *
  23265. * @param jointData The data for the Distance-Joint
  23266. */
  23267. constructor(jointData: DistanceJointData);
  23268. /**
  23269. * Update the predefined distance.
  23270. * @param maxDistance The maximum preferred distance
  23271. * @param minDistance The minimum preferred distance
  23272. */
  23273. updateDistance(maxDistance: number, minDistance?: number): void;
  23274. }
  23275. /**
  23276. * Represents a Motor-Enabled Joint
  23277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23278. */
  23279. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23280. /**
  23281. * Initializes the Motor-Enabled Joint
  23282. * @param type The type of the joint
  23283. * @param jointData The physica joint data for the joint
  23284. */
  23285. constructor(type: number, jointData: PhysicsJointData);
  23286. /**
  23287. * Set the motor values.
  23288. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23289. * @param force the force to apply
  23290. * @param maxForce max force for this motor.
  23291. */
  23292. setMotor(force?: number, maxForce?: number): void;
  23293. /**
  23294. * Set the motor's limits.
  23295. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23296. * @param upperLimit The upper limit of the motor
  23297. * @param lowerLimit The lower limit of the motor
  23298. */
  23299. setLimit(upperLimit: number, lowerLimit?: number): void;
  23300. }
  23301. /**
  23302. * This class represents a single physics Hinge-Joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export class HingeJoint extends MotorEnabledJoint {
  23306. /**
  23307. * Initializes the Hinge-Joint
  23308. * @param jointData The joint data for the Hinge-Joint
  23309. */
  23310. constructor(jointData: PhysicsJointData);
  23311. /**
  23312. * Set the motor values.
  23313. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23314. * @param {number} force the force to apply
  23315. * @param {number} maxForce max force for this motor.
  23316. */
  23317. setMotor(force?: number, maxForce?: number): void;
  23318. /**
  23319. * Set the motor's limits.
  23320. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23321. * @param upperLimit The upper limit of the motor
  23322. * @param lowerLimit The lower limit of the motor
  23323. */
  23324. setLimit(upperLimit: number, lowerLimit?: number): void;
  23325. }
  23326. /**
  23327. * This class represents a dual hinge physics joint (same as wheel joint)
  23328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23329. */
  23330. export class Hinge2Joint extends MotorEnabledJoint {
  23331. /**
  23332. * Initializes the Hinge2-Joint
  23333. * @param jointData The joint data for the Hinge2-Joint
  23334. */
  23335. constructor(jointData: PhysicsJointData);
  23336. /**
  23337. * Set the motor values.
  23338. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23339. * @param {number} targetSpeed the speed the motor is to reach
  23340. * @param {number} maxForce max force for this motor.
  23341. * @param {motorIndex} the motor's index, 0 or 1.
  23342. */
  23343. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23344. /**
  23345. * Set the motor limits.
  23346. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23347. * @param {number} upperLimit the upper limit
  23348. * @param {number} lowerLimit lower limit
  23349. * @param {motorIndex} the motor's index, 0 or 1.
  23350. */
  23351. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23352. }
  23353. /**
  23354. * Interface for a motor enabled joint
  23355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23356. */
  23357. export interface IMotorEnabledJoint {
  23358. /**
  23359. * Physics joint
  23360. */
  23361. physicsJoint: any;
  23362. /**
  23363. * Sets the motor of the motor-enabled joint
  23364. * @param force The force of the motor
  23365. * @param maxForce The maximum force of the motor
  23366. * @param motorIndex The index of the motor
  23367. */
  23368. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23369. /**
  23370. * Sets the limit of the motor
  23371. * @param upperLimit The upper limit of the motor
  23372. * @param lowerLimit The lower limit of the motor
  23373. * @param motorIndex The index of the motor
  23374. */
  23375. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23376. }
  23377. /**
  23378. * Joint data for a Distance-Joint
  23379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23380. */
  23381. export interface DistanceJointData extends PhysicsJointData {
  23382. /**
  23383. * Max distance the 2 joint objects can be apart
  23384. */
  23385. maxDistance: number;
  23386. }
  23387. /**
  23388. * Joint data from a spring joint
  23389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23390. */
  23391. export interface SpringJointData extends PhysicsJointData {
  23392. /**
  23393. * Length of the spring
  23394. */
  23395. length: number;
  23396. /**
  23397. * Stiffness of the spring
  23398. */
  23399. stiffness: number;
  23400. /**
  23401. * Damping of the spring
  23402. */
  23403. damping: number;
  23404. /** this callback will be called when applying the force to the impostors. */
  23405. forceApplicationCallback: () => void;
  23406. }
  23407. }
  23408. declare module BABYLON {
  23409. /**
  23410. * Holds the data for the raycast result
  23411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23412. */
  23413. export class PhysicsRaycastResult {
  23414. private _hasHit;
  23415. private _hitDistance;
  23416. private _hitNormalWorld;
  23417. private _hitPointWorld;
  23418. private _rayFromWorld;
  23419. private _rayToWorld;
  23420. /**
  23421. * Gets if there was a hit
  23422. */
  23423. get hasHit(): boolean;
  23424. /**
  23425. * Gets the distance from the hit
  23426. */
  23427. get hitDistance(): number;
  23428. /**
  23429. * Gets the hit normal/direction in the world
  23430. */
  23431. get hitNormalWorld(): Vector3;
  23432. /**
  23433. * Gets the hit point in the world
  23434. */
  23435. get hitPointWorld(): Vector3;
  23436. /**
  23437. * Gets the ray "start point" of the ray in the world
  23438. */
  23439. get rayFromWorld(): Vector3;
  23440. /**
  23441. * Gets the ray "end point" of the ray in the world
  23442. */
  23443. get rayToWorld(): Vector3;
  23444. /**
  23445. * Sets the hit data (normal & point in world space)
  23446. * @param hitNormalWorld defines the normal in world space
  23447. * @param hitPointWorld defines the point in world space
  23448. */
  23449. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23450. /**
  23451. * Sets the distance from the start point to the hit point
  23452. * @param distance
  23453. */
  23454. setHitDistance(distance: number): void;
  23455. /**
  23456. * Calculates the distance manually
  23457. */
  23458. calculateHitDistance(): void;
  23459. /**
  23460. * Resets all the values to default
  23461. * @param from The from point on world space
  23462. * @param to The to point on world space
  23463. */
  23464. reset(from?: Vector3, to?: Vector3): void;
  23465. }
  23466. /**
  23467. * Interface for the size containing width and height
  23468. */
  23469. interface IXYZ {
  23470. /**
  23471. * X
  23472. */
  23473. x: number;
  23474. /**
  23475. * Y
  23476. */
  23477. y: number;
  23478. /**
  23479. * Z
  23480. */
  23481. z: number;
  23482. }
  23483. }
  23484. declare module BABYLON {
  23485. /**
  23486. * Interface used to describe a physics joint
  23487. */
  23488. export interface PhysicsImpostorJoint {
  23489. /** Defines the main impostor to which the joint is linked */
  23490. mainImpostor: PhysicsImpostor;
  23491. /** Defines the impostor that is connected to the main impostor using this joint */
  23492. connectedImpostor: PhysicsImpostor;
  23493. /** Defines the joint itself */
  23494. joint: PhysicsJoint;
  23495. }
  23496. /** @hidden */
  23497. export interface IPhysicsEnginePlugin {
  23498. world: any;
  23499. name: string;
  23500. setGravity(gravity: Vector3): void;
  23501. setTimeStep(timeStep: number): void;
  23502. getTimeStep(): number;
  23503. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23504. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23505. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23506. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23507. removePhysicsBody(impostor: PhysicsImpostor): void;
  23508. generateJoint(joint: PhysicsImpostorJoint): void;
  23509. removeJoint(joint: PhysicsImpostorJoint): void;
  23510. isSupported(): boolean;
  23511. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23512. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23513. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23514. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23515. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23516. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23517. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23518. getBodyMass(impostor: PhysicsImpostor): number;
  23519. getBodyFriction(impostor: PhysicsImpostor): number;
  23520. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23521. getBodyRestitution(impostor: PhysicsImpostor): number;
  23522. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23523. getBodyPressure?(impostor: PhysicsImpostor): number;
  23524. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23525. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23526. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23527. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23528. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23529. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23530. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23531. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23532. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23533. sleepBody(impostor: PhysicsImpostor): void;
  23534. wakeUpBody(impostor: PhysicsImpostor): void;
  23535. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23536. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23537. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23538. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23539. getRadius(impostor: PhysicsImpostor): number;
  23540. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23541. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23542. dispose(): void;
  23543. }
  23544. /**
  23545. * Interface used to define a physics engine
  23546. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23547. */
  23548. export interface IPhysicsEngine {
  23549. /**
  23550. * Gets the gravity vector used by the simulation
  23551. */
  23552. gravity: Vector3;
  23553. /**
  23554. * Sets the gravity vector used by the simulation
  23555. * @param gravity defines the gravity vector to use
  23556. */
  23557. setGravity(gravity: Vector3): void;
  23558. /**
  23559. * Set the time step of the physics engine.
  23560. * Default is 1/60.
  23561. * To slow it down, enter 1/600 for example.
  23562. * To speed it up, 1/30
  23563. * @param newTimeStep the new timestep to apply to this world.
  23564. */
  23565. setTimeStep(newTimeStep: number): void;
  23566. /**
  23567. * Get the time step of the physics engine.
  23568. * @returns the current time step
  23569. */
  23570. getTimeStep(): number;
  23571. /**
  23572. * Set the sub time step of the physics engine.
  23573. * Default is 0 meaning there is no sub steps
  23574. * To increase physics resolution precision, set a small value (like 1 ms)
  23575. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23576. */
  23577. setSubTimeStep(subTimeStep: number): void;
  23578. /**
  23579. * Get the sub time step of the physics engine.
  23580. * @returns the current sub time step
  23581. */
  23582. getSubTimeStep(): number;
  23583. /**
  23584. * Release all resources
  23585. */
  23586. dispose(): void;
  23587. /**
  23588. * Gets the name of the current physics plugin
  23589. * @returns the name of the plugin
  23590. */
  23591. getPhysicsPluginName(): string;
  23592. /**
  23593. * Adding a new impostor for the impostor tracking.
  23594. * This will be done by the impostor itself.
  23595. * @param impostor the impostor to add
  23596. */
  23597. addImpostor(impostor: PhysicsImpostor): void;
  23598. /**
  23599. * Remove an impostor from the engine.
  23600. * This impostor and its mesh will not longer be updated by the physics engine.
  23601. * @param impostor the impostor to remove
  23602. */
  23603. removeImpostor(impostor: PhysicsImpostor): void;
  23604. /**
  23605. * Add a joint to the physics engine
  23606. * @param mainImpostor defines the main impostor to which the joint is added.
  23607. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23608. * @param joint defines the joint that will connect both impostors.
  23609. */
  23610. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23611. /**
  23612. * Removes a joint from the simulation
  23613. * @param mainImpostor defines the impostor used with the joint
  23614. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23615. * @param joint defines the joint to remove
  23616. */
  23617. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23618. /**
  23619. * Gets the current plugin used to run the simulation
  23620. * @returns current plugin
  23621. */
  23622. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23623. /**
  23624. * Gets the list of physic impostors
  23625. * @returns an array of PhysicsImpostor
  23626. */
  23627. getImpostors(): Array<PhysicsImpostor>;
  23628. /**
  23629. * Gets the impostor for a physics enabled object
  23630. * @param object defines the object impersonated by the impostor
  23631. * @returns the PhysicsImpostor or null if not found
  23632. */
  23633. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23634. /**
  23635. * Gets the impostor for a physics body object
  23636. * @param body defines physics body used by the impostor
  23637. * @returns the PhysicsImpostor or null if not found
  23638. */
  23639. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23640. /**
  23641. * Does a raycast in the physics world
  23642. * @param from when should the ray start?
  23643. * @param to when should the ray end?
  23644. * @returns PhysicsRaycastResult
  23645. */
  23646. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23647. /**
  23648. * Called by the scene. No need to call it.
  23649. * @param delta defines the timespam between frames
  23650. */
  23651. _step(delta: number): void;
  23652. }
  23653. }
  23654. declare module BABYLON {
  23655. /**
  23656. * The interface for the physics imposter parameters
  23657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23658. */
  23659. export interface PhysicsImpostorParameters {
  23660. /**
  23661. * The mass of the physics imposter
  23662. */
  23663. mass: number;
  23664. /**
  23665. * The friction of the physics imposter
  23666. */
  23667. friction?: number;
  23668. /**
  23669. * The coefficient of restitution of the physics imposter
  23670. */
  23671. restitution?: number;
  23672. /**
  23673. * The native options of the physics imposter
  23674. */
  23675. nativeOptions?: any;
  23676. /**
  23677. * Specifies if the parent should be ignored
  23678. */
  23679. ignoreParent?: boolean;
  23680. /**
  23681. * Specifies if bi-directional transformations should be disabled
  23682. */
  23683. disableBidirectionalTransformation?: boolean;
  23684. /**
  23685. * The pressure inside the physics imposter, soft object only
  23686. */
  23687. pressure?: number;
  23688. /**
  23689. * The stiffness the physics imposter, soft object only
  23690. */
  23691. stiffness?: number;
  23692. /**
  23693. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23694. */
  23695. velocityIterations?: number;
  23696. /**
  23697. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23698. */
  23699. positionIterations?: number;
  23700. /**
  23701. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23702. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23703. * Add to fix multiple points
  23704. */
  23705. fixedPoints?: number;
  23706. /**
  23707. * The collision margin around a soft object
  23708. */
  23709. margin?: number;
  23710. /**
  23711. * The collision margin around a soft object
  23712. */
  23713. damping?: number;
  23714. /**
  23715. * The path for a rope based on an extrusion
  23716. */
  23717. path?: any;
  23718. /**
  23719. * The shape of an extrusion used for a rope based on an extrusion
  23720. */
  23721. shape?: any;
  23722. }
  23723. /**
  23724. * Interface for a physics-enabled object
  23725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23726. */
  23727. export interface IPhysicsEnabledObject {
  23728. /**
  23729. * The position of the physics-enabled object
  23730. */
  23731. position: Vector3;
  23732. /**
  23733. * The rotation of the physics-enabled object
  23734. */
  23735. rotationQuaternion: Nullable<Quaternion>;
  23736. /**
  23737. * The scale of the physics-enabled object
  23738. */
  23739. scaling: Vector3;
  23740. /**
  23741. * The rotation of the physics-enabled object
  23742. */
  23743. rotation?: Vector3;
  23744. /**
  23745. * The parent of the physics-enabled object
  23746. */
  23747. parent?: any;
  23748. /**
  23749. * The bounding info of the physics-enabled object
  23750. * @returns The bounding info of the physics-enabled object
  23751. */
  23752. getBoundingInfo(): BoundingInfo;
  23753. /**
  23754. * Computes the world matrix
  23755. * @param force Specifies if the world matrix should be computed by force
  23756. * @returns A world matrix
  23757. */
  23758. computeWorldMatrix(force: boolean): Matrix;
  23759. /**
  23760. * Gets the world matrix
  23761. * @returns A world matrix
  23762. */
  23763. getWorldMatrix?(): Matrix;
  23764. /**
  23765. * Gets the child meshes
  23766. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23767. * @returns An array of abstract meshes
  23768. */
  23769. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23770. /**
  23771. * Gets the vertex data
  23772. * @param kind The type of vertex data
  23773. * @returns A nullable array of numbers, or a float32 array
  23774. */
  23775. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23776. /**
  23777. * Gets the indices from the mesh
  23778. * @returns A nullable array of index arrays
  23779. */
  23780. getIndices?(): Nullable<IndicesArray>;
  23781. /**
  23782. * Gets the scene from the mesh
  23783. * @returns the indices array or null
  23784. */
  23785. getScene?(): Scene;
  23786. /**
  23787. * Gets the absolute position from the mesh
  23788. * @returns the absolute position
  23789. */
  23790. getAbsolutePosition(): Vector3;
  23791. /**
  23792. * Gets the absolute pivot point from the mesh
  23793. * @returns the absolute pivot point
  23794. */
  23795. getAbsolutePivotPoint(): Vector3;
  23796. /**
  23797. * Rotates the mesh
  23798. * @param axis The axis of rotation
  23799. * @param amount The amount of rotation
  23800. * @param space The space of the rotation
  23801. * @returns The rotation transform node
  23802. */
  23803. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23804. /**
  23805. * Translates the mesh
  23806. * @param axis The axis of translation
  23807. * @param distance The distance of translation
  23808. * @param space The space of the translation
  23809. * @returns The transform node
  23810. */
  23811. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23812. /**
  23813. * Sets the absolute position of the mesh
  23814. * @param absolutePosition The absolute position of the mesh
  23815. * @returns The transform node
  23816. */
  23817. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23818. /**
  23819. * Gets the class name of the mesh
  23820. * @returns The class name
  23821. */
  23822. getClassName(): string;
  23823. }
  23824. /**
  23825. * Represents a physics imposter
  23826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23827. */
  23828. export class PhysicsImpostor {
  23829. /**
  23830. * The physics-enabled object used as the physics imposter
  23831. */
  23832. object: IPhysicsEnabledObject;
  23833. /**
  23834. * The type of the physics imposter
  23835. */
  23836. type: number;
  23837. private _options;
  23838. private _scene?;
  23839. /**
  23840. * The default object size of the imposter
  23841. */
  23842. static DEFAULT_OBJECT_SIZE: Vector3;
  23843. /**
  23844. * The identity quaternion of the imposter
  23845. */
  23846. static IDENTITY_QUATERNION: Quaternion;
  23847. /** @hidden */
  23848. _pluginData: any;
  23849. private _physicsEngine;
  23850. private _physicsBody;
  23851. private _bodyUpdateRequired;
  23852. private _onBeforePhysicsStepCallbacks;
  23853. private _onAfterPhysicsStepCallbacks;
  23854. /** @hidden */
  23855. _onPhysicsCollideCallbacks: Array<{
  23856. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23857. otherImpostors: Array<PhysicsImpostor>;
  23858. }>;
  23859. private _deltaPosition;
  23860. private _deltaRotation;
  23861. private _deltaRotationConjugated;
  23862. /** @hidden */
  23863. _isFromLine: boolean;
  23864. private _parent;
  23865. private _isDisposed;
  23866. private static _tmpVecs;
  23867. private static _tmpQuat;
  23868. /**
  23869. * Specifies if the physics imposter is disposed
  23870. */
  23871. get isDisposed(): boolean;
  23872. /**
  23873. * Gets the mass of the physics imposter
  23874. */
  23875. get mass(): number;
  23876. set mass(value: number);
  23877. /**
  23878. * Gets the coefficient of friction
  23879. */
  23880. get friction(): number;
  23881. /**
  23882. * Sets the coefficient of friction
  23883. */
  23884. set friction(value: number);
  23885. /**
  23886. * Gets the coefficient of restitution
  23887. */
  23888. get restitution(): number;
  23889. /**
  23890. * Sets the coefficient of restitution
  23891. */
  23892. set restitution(value: number);
  23893. /**
  23894. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23895. */
  23896. get pressure(): number;
  23897. /**
  23898. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23899. */
  23900. set pressure(value: number);
  23901. /**
  23902. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23903. */
  23904. get stiffness(): number;
  23905. /**
  23906. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23907. */
  23908. set stiffness(value: number);
  23909. /**
  23910. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23911. */
  23912. get velocityIterations(): number;
  23913. /**
  23914. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23915. */
  23916. set velocityIterations(value: number);
  23917. /**
  23918. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23919. */
  23920. get positionIterations(): number;
  23921. /**
  23922. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23923. */
  23924. set positionIterations(value: number);
  23925. /**
  23926. * The unique id of the physics imposter
  23927. * set by the physics engine when adding this impostor to the array
  23928. */
  23929. uniqueId: number;
  23930. /**
  23931. * @hidden
  23932. */
  23933. soft: boolean;
  23934. /**
  23935. * @hidden
  23936. */
  23937. segments: number;
  23938. private _joints;
  23939. /**
  23940. * Initializes the physics imposter
  23941. * @param object The physics-enabled object used as the physics imposter
  23942. * @param type The type of the physics imposter
  23943. * @param _options The options for the physics imposter
  23944. * @param _scene The Babylon scene
  23945. */
  23946. constructor(
  23947. /**
  23948. * The physics-enabled object used as the physics imposter
  23949. */
  23950. object: IPhysicsEnabledObject,
  23951. /**
  23952. * The type of the physics imposter
  23953. */
  23954. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23955. /**
  23956. * This function will completly initialize this impostor.
  23957. * It will create a new body - but only if this mesh has no parent.
  23958. * If it has, this impostor will not be used other than to define the impostor
  23959. * of the child mesh.
  23960. * @hidden
  23961. */
  23962. _init(): void;
  23963. private _getPhysicsParent;
  23964. /**
  23965. * Should a new body be generated.
  23966. * @returns boolean specifying if body initialization is required
  23967. */
  23968. isBodyInitRequired(): boolean;
  23969. /**
  23970. * Sets the updated scaling
  23971. * @param updated Specifies if the scaling is updated
  23972. */
  23973. setScalingUpdated(): void;
  23974. /**
  23975. * Force a regeneration of this or the parent's impostor's body.
  23976. * Use under cautious - This will remove all joints already implemented.
  23977. */
  23978. forceUpdate(): void;
  23979. /**
  23980. * Gets the body that holds this impostor. Either its own, or its parent.
  23981. */
  23982. get physicsBody(): any;
  23983. /**
  23984. * Get the parent of the physics imposter
  23985. * @returns Physics imposter or null
  23986. */
  23987. get parent(): Nullable<PhysicsImpostor>;
  23988. /**
  23989. * Sets the parent of the physics imposter
  23990. */
  23991. set parent(value: Nullable<PhysicsImpostor>);
  23992. /**
  23993. * Set the physics body. Used mainly by the physics engine/plugin
  23994. */
  23995. set physicsBody(physicsBody: any);
  23996. /**
  23997. * Resets the update flags
  23998. */
  23999. resetUpdateFlags(): void;
  24000. /**
  24001. * Gets the object extend size
  24002. * @returns the object extend size
  24003. */
  24004. getObjectExtendSize(): Vector3;
  24005. /**
  24006. * Gets the object center
  24007. * @returns The object center
  24008. */
  24009. getObjectCenter(): Vector3;
  24010. /**
  24011. * Get a specific parameter from the options parameters
  24012. * @param paramName The object parameter name
  24013. * @returns The object parameter
  24014. */
  24015. getParam(paramName: string): any;
  24016. /**
  24017. * Sets a specific parameter in the options given to the physics plugin
  24018. * @param paramName The parameter name
  24019. * @param value The value of the parameter
  24020. */
  24021. setParam(paramName: string, value: number): void;
  24022. /**
  24023. * Specifically change the body's mass option. Won't recreate the physics body object
  24024. * @param mass The mass of the physics imposter
  24025. */
  24026. setMass(mass: number): void;
  24027. /**
  24028. * Gets the linear velocity
  24029. * @returns linear velocity or null
  24030. */
  24031. getLinearVelocity(): Nullable<Vector3>;
  24032. /**
  24033. * Sets the linear velocity
  24034. * @param velocity linear velocity or null
  24035. */
  24036. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24037. /**
  24038. * Gets the angular velocity
  24039. * @returns angular velocity or null
  24040. */
  24041. getAngularVelocity(): Nullable<Vector3>;
  24042. /**
  24043. * Sets the angular velocity
  24044. * @param velocity The velocity or null
  24045. */
  24046. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24047. /**
  24048. * Execute a function with the physics plugin native code
  24049. * Provide a function the will have two variables - the world object and the physics body object
  24050. * @param func The function to execute with the physics plugin native code
  24051. */
  24052. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24053. /**
  24054. * Register a function that will be executed before the physics world is stepping forward
  24055. * @param func The function to execute before the physics world is stepped forward
  24056. */
  24057. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24058. /**
  24059. * Unregister a function that will be executed before the physics world is stepping forward
  24060. * @param func The function to execute before the physics world is stepped forward
  24061. */
  24062. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24063. /**
  24064. * Register a function that will be executed after the physics step
  24065. * @param func The function to execute after physics step
  24066. */
  24067. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24068. /**
  24069. * Unregisters a function that will be executed after the physics step
  24070. * @param func The function to execute after physics step
  24071. */
  24072. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24073. /**
  24074. * register a function that will be executed when this impostor collides against a different body
  24075. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24076. * @param func Callback that is executed on collision
  24077. */
  24078. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24079. /**
  24080. * Unregisters the physics imposter on contact
  24081. * @param collideAgainst The physics object to collide against
  24082. * @param func Callback to execute on collision
  24083. */
  24084. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24085. private _tmpQuat;
  24086. private _tmpQuat2;
  24087. /**
  24088. * Get the parent rotation
  24089. * @returns The parent rotation
  24090. */
  24091. getParentsRotation(): Quaternion;
  24092. /**
  24093. * this function is executed by the physics engine.
  24094. */
  24095. beforeStep: () => void;
  24096. /**
  24097. * this function is executed by the physics engine
  24098. */
  24099. afterStep: () => void;
  24100. /**
  24101. * Legacy collision detection event support
  24102. */
  24103. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24104. /**
  24105. * event and body object due to cannon's event-based architecture.
  24106. */
  24107. onCollide: (e: {
  24108. body: any;
  24109. }) => void;
  24110. /**
  24111. * Apply a force
  24112. * @param force The force to apply
  24113. * @param contactPoint The contact point for the force
  24114. * @returns The physics imposter
  24115. */
  24116. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24117. /**
  24118. * Apply an impulse
  24119. * @param force The impulse force
  24120. * @param contactPoint The contact point for the impulse force
  24121. * @returns The physics imposter
  24122. */
  24123. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24124. /**
  24125. * A help function to create a joint
  24126. * @param otherImpostor A physics imposter used to create a joint
  24127. * @param jointType The type of joint
  24128. * @param jointData The data for the joint
  24129. * @returns The physics imposter
  24130. */
  24131. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24132. /**
  24133. * Add a joint to this impostor with a different impostor
  24134. * @param otherImpostor A physics imposter used to add a joint
  24135. * @param joint The joint to add
  24136. * @returns The physics imposter
  24137. */
  24138. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24139. /**
  24140. * Add an anchor to a cloth impostor
  24141. * @param otherImpostor rigid impostor to anchor to
  24142. * @param width ratio across width from 0 to 1
  24143. * @param height ratio up height from 0 to 1
  24144. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24145. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24146. * @returns impostor the soft imposter
  24147. */
  24148. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24149. /**
  24150. * Add a hook to a rope impostor
  24151. * @param otherImpostor rigid impostor to anchor to
  24152. * @param length ratio across rope from 0 to 1
  24153. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24154. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24155. * @returns impostor the rope imposter
  24156. */
  24157. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24158. /**
  24159. * Will keep this body still, in a sleep mode.
  24160. * @returns the physics imposter
  24161. */
  24162. sleep(): PhysicsImpostor;
  24163. /**
  24164. * Wake the body up.
  24165. * @returns The physics imposter
  24166. */
  24167. wakeUp(): PhysicsImpostor;
  24168. /**
  24169. * Clones the physics imposter
  24170. * @param newObject The physics imposter clones to this physics-enabled object
  24171. * @returns A nullable physics imposter
  24172. */
  24173. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24174. /**
  24175. * Disposes the physics imposter
  24176. */
  24177. dispose(): void;
  24178. /**
  24179. * Sets the delta position
  24180. * @param position The delta position amount
  24181. */
  24182. setDeltaPosition(position: Vector3): void;
  24183. /**
  24184. * Sets the delta rotation
  24185. * @param rotation The delta rotation amount
  24186. */
  24187. setDeltaRotation(rotation: Quaternion): void;
  24188. /**
  24189. * Gets the box size of the physics imposter and stores the result in the input parameter
  24190. * @param result Stores the box size
  24191. * @returns The physics imposter
  24192. */
  24193. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24194. /**
  24195. * Gets the radius of the physics imposter
  24196. * @returns Radius of the physics imposter
  24197. */
  24198. getRadius(): number;
  24199. /**
  24200. * Sync a bone with this impostor
  24201. * @param bone The bone to sync to the impostor.
  24202. * @param boneMesh The mesh that the bone is influencing.
  24203. * @param jointPivot The pivot of the joint / bone in local space.
  24204. * @param distToJoint Optional distance from the impostor to the joint.
  24205. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24206. */
  24207. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24208. /**
  24209. * Sync impostor to a bone
  24210. * @param bone The bone that the impostor will be synced to.
  24211. * @param boneMesh The mesh that the bone is influencing.
  24212. * @param jointPivot The pivot of the joint / bone in local space.
  24213. * @param distToJoint Optional distance from the impostor to the joint.
  24214. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24215. * @param boneAxis Optional vector3 axis the bone is aligned with
  24216. */
  24217. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24218. /**
  24219. * No-Imposter type
  24220. */
  24221. static NoImpostor: number;
  24222. /**
  24223. * Sphere-Imposter type
  24224. */
  24225. static SphereImpostor: number;
  24226. /**
  24227. * Box-Imposter type
  24228. */
  24229. static BoxImpostor: number;
  24230. /**
  24231. * Plane-Imposter type
  24232. */
  24233. static PlaneImpostor: number;
  24234. /**
  24235. * Mesh-imposter type
  24236. */
  24237. static MeshImpostor: number;
  24238. /**
  24239. * Capsule-Impostor type (Ammo.js plugin only)
  24240. */
  24241. static CapsuleImpostor: number;
  24242. /**
  24243. * Cylinder-Imposter type
  24244. */
  24245. static CylinderImpostor: number;
  24246. /**
  24247. * Particle-Imposter type
  24248. */
  24249. static ParticleImpostor: number;
  24250. /**
  24251. * Heightmap-Imposter type
  24252. */
  24253. static HeightmapImpostor: number;
  24254. /**
  24255. * ConvexHull-Impostor type (Ammo.js plugin only)
  24256. */
  24257. static ConvexHullImpostor: number;
  24258. /**
  24259. * Custom-Imposter type (Ammo.js plugin only)
  24260. */
  24261. static CustomImpostor: number;
  24262. /**
  24263. * Rope-Imposter type
  24264. */
  24265. static RopeImpostor: number;
  24266. /**
  24267. * Cloth-Imposter type
  24268. */
  24269. static ClothImpostor: number;
  24270. /**
  24271. * Softbody-Imposter type
  24272. */
  24273. static SoftbodyImpostor: number;
  24274. }
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * @hidden
  24279. **/
  24280. export class _CreationDataStorage {
  24281. closePath?: boolean;
  24282. closeArray?: boolean;
  24283. idx: number[];
  24284. dashSize: number;
  24285. gapSize: number;
  24286. path3D: Path3D;
  24287. pathArray: Vector3[][];
  24288. arc: number;
  24289. radius: number;
  24290. cap: number;
  24291. tessellation: number;
  24292. }
  24293. /**
  24294. * @hidden
  24295. **/
  24296. class _InstanceDataStorage {
  24297. visibleInstances: any;
  24298. batchCache: _InstancesBatch;
  24299. instancesBufferSize: number;
  24300. instancesBuffer: Nullable<Buffer>;
  24301. instancesData: Float32Array;
  24302. overridenInstanceCount: number;
  24303. isFrozen: boolean;
  24304. previousBatch: Nullable<_InstancesBatch>;
  24305. hardwareInstancedRendering: boolean;
  24306. sideOrientation: number;
  24307. manualUpdate: boolean;
  24308. }
  24309. /**
  24310. * @hidden
  24311. **/
  24312. export class _InstancesBatch {
  24313. mustReturn: boolean;
  24314. visibleInstances: Nullable<InstancedMesh[]>[];
  24315. renderSelf: boolean[];
  24316. hardwareInstancedRendering: boolean[];
  24317. }
  24318. /**
  24319. * Class used to represent renderable models
  24320. */
  24321. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24322. /**
  24323. * Mesh side orientation : usually the external or front surface
  24324. */
  24325. static readonly FRONTSIDE: number;
  24326. /**
  24327. * Mesh side orientation : usually the internal or back surface
  24328. */
  24329. static readonly BACKSIDE: number;
  24330. /**
  24331. * Mesh side orientation : both internal and external or front and back surfaces
  24332. */
  24333. static readonly DOUBLESIDE: number;
  24334. /**
  24335. * Mesh side orientation : by default, `FRONTSIDE`
  24336. */
  24337. static readonly DEFAULTSIDE: number;
  24338. /**
  24339. * Mesh cap setting : no cap
  24340. */
  24341. static readonly NO_CAP: number;
  24342. /**
  24343. * Mesh cap setting : one cap at the beginning of the mesh
  24344. */
  24345. static readonly CAP_START: number;
  24346. /**
  24347. * Mesh cap setting : one cap at the end of the mesh
  24348. */
  24349. static readonly CAP_END: number;
  24350. /**
  24351. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24352. */
  24353. static readonly CAP_ALL: number;
  24354. /**
  24355. * Mesh pattern setting : no flip or rotate
  24356. */
  24357. static readonly NO_FLIP: number;
  24358. /**
  24359. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24360. */
  24361. static readonly FLIP_TILE: number;
  24362. /**
  24363. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24364. */
  24365. static readonly ROTATE_TILE: number;
  24366. /**
  24367. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24368. */
  24369. static readonly FLIP_ROW: number;
  24370. /**
  24371. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24372. */
  24373. static readonly ROTATE_ROW: number;
  24374. /**
  24375. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24376. */
  24377. static readonly FLIP_N_ROTATE_TILE: number;
  24378. /**
  24379. * Mesh pattern setting : rotate pattern and rotate
  24380. */
  24381. static readonly FLIP_N_ROTATE_ROW: number;
  24382. /**
  24383. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24384. */
  24385. static readonly CENTER: number;
  24386. /**
  24387. * Mesh tile positioning : part tiles on left
  24388. */
  24389. static readonly LEFT: number;
  24390. /**
  24391. * Mesh tile positioning : part tiles on right
  24392. */
  24393. static readonly RIGHT: number;
  24394. /**
  24395. * Mesh tile positioning : part tiles on top
  24396. */
  24397. static readonly TOP: number;
  24398. /**
  24399. * Mesh tile positioning : part tiles on bottom
  24400. */
  24401. static readonly BOTTOM: number;
  24402. /**
  24403. * Gets the default side orientation.
  24404. * @param orientation the orientation to value to attempt to get
  24405. * @returns the default orientation
  24406. * @hidden
  24407. */
  24408. static _GetDefaultSideOrientation(orientation?: number): number;
  24409. private _internalMeshDataInfo;
  24410. /**
  24411. * An event triggered before rendering the mesh
  24412. */
  24413. get onBeforeRenderObservable(): Observable<Mesh>;
  24414. /**
  24415. * An event triggered before binding the mesh
  24416. */
  24417. get onBeforeBindObservable(): Observable<Mesh>;
  24418. /**
  24419. * An event triggered after rendering the mesh
  24420. */
  24421. get onAfterRenderObservable(): Observable<Mesh>;
  24422. /**
  24423. * An event triggered before drawing the mesh
  24424. */
  24425. get onBeforeDrawObservable(): Observable<Mesh>;
  24426. private _onBeforeDrawObserver;
  24427. /**
  24428. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24429. */
  24430. set onBeforeDraw(callback: () => void);
  24431. get hasInstances(): boolean;
  24432. /**
  24433. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24434. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24435. */
  24436. delayLoadState: number;
  24437. /**
  24438. * Gets the list of instances created from this mesh
  24439. * it is not supposed to be modified manually.
  24440. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24442. */
  24443. instances: InstancedMesh[];
  24444. /**
  24445. * Gets the file containing delay loading data for this mesh
  24446. */
  24447. delayLoadingFile: string;
  24448. /** @hidden */
  24449. _binaryInfo: any;
  24450. /**
  24451. * User defined function used to change how LOD level selection is done
  24452. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24453. */
  24454. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24455. /**
  24456. * Gets or sets the morph target manager
  24457. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24458. */
  24459. get morphTargetManager(): Nullable<MorphTargetManager>;
  24460. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24461. /** @hidden */
  24462. _creationDataStorage: Nullable<_CreationDataStorage>;
  24463. /** @hidden */
  24464. _geometry: Nullable<Geometry>;
  24465. /** @hidden */
  24466. _delayInfo: Array<string>;
  24467. /** @hidden */
  24468. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24469. /** @hidden */
  24470. _instanceDataStorage: _InstanceDataStorage;
  24471. private _effectiveMaterial;
  24472. /** @hidden */
  24473. _shouldGenerateFlatShading: boolean;
  24474. /** @hidden */
  24475. _originalBuilderSideOrientation: number;
  24476. /**
  24477. * Use this property to change the original side orientation defined at construction time
  24478. */
  24479. overrideMaterialSideOrientation: Nullable<number>;
  24480. /**
  24481. * Gets the source mesh (the one used to clone this one from)
  24482. */
  24483. get source(): Nullable<Mesh>;
  24484. /**
  24485. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24486. */
  24487. get isUnIndexed(): boolean;
  24488. set isUnIndexed(value: boolean);
  24489. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24490. get worldMatrixInstancedBuffer(): Float32Array;
  24491. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24492. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24493. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24494. /**
  24495. * @constructor
  24496. * @param name The value used by scene.getMeshByName() to do a lookup.
  24497. * @param scene The scene to add this mesh to.
  24498. * @param parent The parent of this mesh, if it has one
  24499. * @param source An optional Mesh from which geometry is shared, cloned.
  24500. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24501. * When false, achieved by calling a clone(), also passing False.
  24502. * This will make creation of children, recursive.
  24503. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24504. */
  24505. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24506. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24507. doNotInstantiate: boolean;
  24508. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24509. /**
  24510. * Gets the class name
  24511. * @returns the string "Mesh".
  24512. */
  24513. getClassName(): string;
  24514. /** @hidden */
  24515. get _isMesh(): boolean;
  24516. /**
  24517. * Returns a description of this mesh
  24518. * @param fullDetails define if full details about this mesh must be used
  24519. * @returns a descriptive string representing this mesh
  24520. */
  24521. toString(fullDetails?: boolean): string;
  24522. /** @hidden */
  24523. _unBindEffect(): void;
  24524. /**
  24525. * Gets a boolean indicating if this mesh has LOD
  24526. */
  24527. get hasLODLevels(): boolean;
  24528. /**
  24529. * Gets the list of MeshLODLevel associated with the current mesh
  24530. * @returns an array of MeshLODLevel
  24531. */
  24532. getLODLevels(): MeshLODLevel[];
  24533. private _sortLODLevels;
  24534. /**
  24535. * Add a mesh as LOD level triggered at the given distance.
  24536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24537. * @param distance The distance from the center of the object to show this level
  24538. * @param mesh The mesh to be added as LOD level (can be null)
  24539. * @return This mesh (for chaining)
  24540. */
  24541. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24542. /**
  24543. * Returns the LOD level mesh at the passed distance or null if not found.
  24544. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24545. * @param distance The distance from the center of the object to show this level
  24546. * @returns a Mesh or `null`
  24547. */
  24548. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24549. /**
  24550. * Remove a mesh from the LOD array
  24551. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24552. * @param mesh defines the mesh to be removed
  24553. * @return This mesh (for chaining)
  24554. */
  24555. removeLODLevel(mesh: Mesh): Mesh;
  24556. /**
  24557. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24558. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24559. * @param camera defines the camera to use to compute distance
  24560. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24561. * @return This mesh (for chaining)
  24562. */
  24563. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24564. /**
  24565. * Gets the mesh internal Geometry object
  24566. */
  24567. get geometry(): Nullable<Geometry>;
  24568. /**
  24569. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24570. * @returns the total number of vertices
  24571. */
  24572. getTotalVertices(): number;
  24573. /**
  24574. * Returns the content of an associated vertex buffer
  24575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24576. * - VertexBuffer.PositionKind
  24577. * - VertexBuffer.UVKind
  24578. * - VertexBuffer.UV2Kind
  24579. * - VertexBuffer.UV3Kind
  24580. * - VertexBuffer.UV4Kind
  24581. * - VertexBuffer.UV5Kind
  24582. * - VertexBuffer.UV6Kind
  24583. * - VertexBuffer.ColorKind
  24584. * - VertexBuffer.MatricesIndicesKind
  24585. * - VertexBuffer.MatricesIndicesExtraKind
  24586. * - VertexBuffer.MatricesWeightsKind
  24587. * - VertexBuffer.MatricesWeightsExtraKind
  24588. * @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
  24589. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24590. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24591. */
  24592. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24593. /**
  24594. * Returns the mesh VertexBuffer object from the requested `kind`
  24595. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24596. * - VertexBuffer.PositionKind
  24597. * - VertexBuffer.NormalKind
  24598. * - VertexBuffer.UVKind
  24599. * - VertexBuffer.UV2Kind
  24600. * - VertexBuffer.UV3Kind
  24601. * - VertexBuffer.UV4Kind
  24602. * - VertexBuffer.UV5Kind
  24603. * - VertexBuffer.UV6Kind
  24604. * - VertexBuffer.ColorKind
  24605. * - VertexBuffer.MatricesIndicesKind
  24606. * - VertexBuffer.MatricesIndicesExtraKind
  24607. * - VertexBuffer.MatricesWeightsKind
  24608. * - VertexBuffer.MatricesWeightsExtraKind
  24609. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24610. */
  24611. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24612. /**
  24613. * Tests if a specific vertex buffer is associated with this mesh
  24614. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24615. * - VertexBuffer.PositionKind
  24616. * - VertexBuffer.NormalKind
  24617. * - VertexBuffer.UVKind
  24618. * - VertexBuffer.UV2Kind
  24619. * - VertexBuffer.UV3Kind
  24620. * - VertexBuffer.UV4Kind
  24621. * - VertexBuffer.UV5Kind
  24622. * - VertexBuffer.UV6Kind
  24623. * - VertexBuffer.ColorKind
  24624. * - VertexBuffer.MatricesIndicesKind
  24625. * - VertexBuffer.MatricesIndicesExtraKind
  24626. * - VertexBuffer.MatricesWeightsKind
  24627. * - VertexBuffer.MatricesWeightsExtraKind
  24628. * @returns a boolean
  24629. */
  24630. isVerticesDataPresent(kind: string): boolean;
  24631. /**
  24632. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24633. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24634. * - VertexBuffer.PositionKind
  24635. * - VertexBuffer.UVKind
  24636. * - VertexBuffer.UV2Kind
  24637. * - VertexBuffer.UV3Kind
  24638. * - VertexBuffer.UV4Kind
  24639. * - VertexBuffer.UV5Kind
  24640. * - VertexBuffer.UV6Kind
  24641. * - VertexBuffer.ColorKind
  24642. * - VertexBuffer.MatricesIndicesKind
  24643. * - VertexBuffer.MatricesIndicesExtraKind
  24644. * - VertexBuffer.MatricesWeightsKind
  24645. * - VertexBuffer.MatricesWeightsExtraKind
  24646. * @returns a boolean
  24647. */
  24648. isVertexBufferUpdatable(kind: string): boolean;
  24649. /**
  24650. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24651. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24652. * - VertexBuffer.PositionKind
  24653. * - VertexBuffer.NormalKind
  24654. * - VertexBuffer.UVKind
  24655. * - VertexBuffer.UV2Kind
  24656. * - VertexBuffer.UV3Kind
  24657. * - VertexBuffer.UV4Kind
  24658. * - VertexBuffer.UV5Kind
  24659. * - VertexBuffer.UV6Kind
  24660. * - VertexBuffer.ColorKind
  24661. * - VertexBuffer.MatricesIndicesKind
  24662. * - VertexBuffer.MatricesIndicesExtraKind
  24663. * - VertexBuffer.MatricesWeightsKind
  24664. * - VertexBuffer.MatricesWeightsExtraKind
  24665. * @returns an array of strings
  24666. */
  24667. getVerticesDataKinds(): string[];
  24668. /**
  24669. * Returns a positive integer : the total number of indices in this mesh geometry.
  24670. * @returns the numner of indices or zero if the mesh has no geometry.
  24671. */
  24672. getTotalIndices(): number;
  24673. /**
  24674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24675. * @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.
  24676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24677. * @returns the indices array or an empty array if the mesh has no geometry
  24678. */
  24679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24680. get isBlocked(): boolean;
  24681. /**
  24682. * Determine if the current mesh is ready to be rendered
  24683. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24684. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24685. * @returns true if all associated assets are ready (material, textures, shaders)
  24686. */
  24687. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24688. /**
  24689. * 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.
  24690. */
  24691. get areNormalsFrozen(): boolean;
  24692. /**
  24693. * 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.
  24694. * @returns the current mesh
  24695. */
  24696. freezeNormals(): Mesh;
  24697. /**
  24698. * 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
  24699. * @returns the current mesh
  24700. */
  24701. unfreezeNormals(): Mesh;
  24702. /**
  24703. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24704. */
  24705. set overridenInstanceCount(count: number);
  24706. /** @hidden */
  24707. _preActivate(): Mesh;
  24708. /** @hidden */
  24709. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24710. /** @hidden */
  24711. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24712. /**
  24713. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24714. * This means the mesh underlying bounding box and sphere are recomputed.
  24715. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24716. * @returns the current mesh
  24717. */
  24718. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24719. /** @hidden */
  24720. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24721. /**
  24722. * This function will subdivide the mesh into multiple submeshes
  24723. * @param count defines the expected number of submeshes
  24724. */
  24725. subdivide(count: number): void;
  24726. /**
  24727. * Copy a FloatArray into a specific associated vertex buffer
  24728. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24729. * - VertexBuffer.PositionKind
  24730. * - VertexBuffer.UVKind
  24731. * - VertexBuffer.UV2Kind
  24732. * - VertexBuffer.UV3Kind
  24733. * - VertexBuffer.UV4Kind
  24734. * - VertexBuffer.UV5Kind
  24735. * - VertexBuffer.UV6Kind
  24736. * - VertexBuffer.ColorKind
  24737. * - VertexBuffer.MatricesIndicesKind
  24738. * - VertexBuffer.MatricesIndicesExtraKind
  24739. * - VertexBuffer.MatricesWeightsKind
  24740. * - VertexBuffer.MatricesWeightsExtraKind
  24741. * @param data defines the data source
  24742. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24743. * @param stride defines the data stride size (can be null)
  24744. * @returns the current mesh
  24745. */
  24746. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24747. /**
  24748. * Delete a vertex buffer associated with this mesh
  24749. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24750. * - VertexBuffer.PositionKind
  24751. * - VertexBuffer.UVKind
  24752. * - VertexBuffer.UV2Kind
  24753. * - VertexBuffer.UV3Kind
  24754. * - VertexBuffer.UV4Kind
  24755. * - VertexBuffer.UV5Kind
  24756. * - VertexBuffer.UV6Kind
  24757. * - VertexBuffer.ColorKind
  24758. * - VertexBuffer.MatricesIndicesKind
  24759. * - VertexBuffer.MatricesIndicesExtraKind
  24760. * - VertexBuffer.MatricesWeightsKind
  24761. * - VertexBuffer.MatricesWeightsExtraKind
  24762. */
  24763. removeVerticesData(kind: string): void;
  24764. /**
  24765. * Flags an associated vertex buffer as updatable
  24766. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24767. * - VertexBuffer.PositionKind
  24768. * - VertexBuffer.UVKind
  24769. * - VertexBuffer.UV2Kind
  24770. * - VertexBuffer.UV3Kind
  24771. * - VertexBuffer.UV4Kind
  24772. * - VertexBuffer.UV5Kind
  24773. * - VertexBuffer.UV6Kind
  24774. * - VertexBuffer.ColorKind
  24775. * - VertexBuffer.MatricesIndicesKind
  24776. * - VertexBuffer.MatricesIndicesExtraKind
  24777. * - VertexBuffer.MatricesWeightsKind
  24778. * - VertexBuffer.MatricesWeightsExtraKind
  24779. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24780. */
  24781. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24782. /**
  24783. * Sets the mesh global Vertex Buffer
  24784. * @param buffer defines the buffer to use
  24785. * @returns the current mesh
  24786. */
  24787. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24788. /**
  24789. * Update a specific associated vertex buffer
  24790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24791. * - VertexBuffer.PositionKind
  24792. * - VertexBuffer.UVKind
  24793. * - VertexBuffer.UV2Kind
  24794. * - VertexBuffer.UV3Kind
  24795. * - VertexBuffer.UV4Kind
  24796. * - VertexBuffer.UV5Kind
  24797. * - VertexBuffer.UV6Kind
  24798. * - VertexBuffer.ColorKind
  24799. * - VertexBuffer.MatricesIndicesKind
  24800. * - VertexBuffer.MatricesIndicesExtraKind
  24801. * - VertexBuffer.MatricesWeightsKind
  24802. * - VertexBuffer.MatricesWeightsExtraKind
  24803. * @param data defines the data source
  24804. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24805. * @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)
  24806. * @returns the current mesh
  24807. */
  24808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24809. /**
  24810. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24811. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24812. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24813. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24814. * @returns the current mesh
  24815. */
  24816. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24817. /**
  24818. * Creates a un-shared specific occurence of the geometry for the mesh.
  24819. * @returns the current mesh
  24820. */
  24821. makeGeometryUnique(): Mesh;
  24822. /**
  24823. * Set the index buffer of this mesh
  24824. * @param indices defines the source data
  24825. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24826. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24827. * @returns the current mesh
  24828. */
  24829. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24830. /**
  24831. * Update the current index buffer
  24832. * @param indices defines the source data
  24833. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24834. * @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)
  24835. * @returns the current mesh
  24836. */
  24837. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24838. /**
  24839. * Invert the geometry to move from a right handed system to a left handed one.
  24840. * @returns the current mesh
  24841. */
  24842. toLeftHanded(): Mesh;
  24843. /** @hidden */
  24844. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24845. /** @hidden */
  24846. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24847. /**
  24848. * Registers for this mesh a javascript function called just before the rendering process
  24849. * @param func defines the function to call before rendering this mesh
  24850. * @returns the current mesh
  24851. */
  24852. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24853. /**
  24854. * Disposes a previously registered javascript function called before the rendering
  24855. * @param func defines the function to remove
  24856. * @returns the current mesh
  24857. */
  24858. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24859. /**
  24860. * Registers for this mesh a javascript function called just after the rendering is complete
  24861. * @param func defines the function to call after rendering this mesh
  24862. * @returns the current mesh
  24863. */
  24864. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24865. /**
  24866. * Disposes a previously registered javascript function called after the rendering.
  24867. * @param func defines the function to remove
  24868. * @returns the current mesh
  24869. */
  24870. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24871. /** @hidden */
  24872. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24873. /** @hidden */
  24874. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24875. /** @hidden */
  24876. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24877. /** @hidden */
  24878. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24879. /** @hidden */
  24880. _rebuild(): void;
  24881. /** @hidden */
  24882. _freeze(): void;
  24883. /** @hidden */
  24884. _unFreeze(): void;
  24885. /**
  24886. * 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
  24887. * @param subMesh defines the subMesh to render
  24888. * @param enableAlphaMode defines if alpha mode can be changed
  24889. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24890. * @returns the current mesh
  24891. */
  24892. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24893. private _onBeforeDraw;
  24894. /**
  24895. * Renormalize the mesh and patch it up if there are no weights
  24896. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24897. * However in the case of zero weights then we set just a single influence to 1.
  24898. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24899. */
  24900. cleanMatrixWeights(): void;
  24901. private normalizeSkinFourWeights;
  24902. private normalizeSkinWeightsAndExtra;
  24903. /**
  24904. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24905. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24906. * the user know there was an issue with importing the mesh
  24907. * @returns a validation object with skinned, valid and report string
  24908. */
  24909. validateSkinning(): {
  24910. skinned: boolean;
  24911. valid: boolean;
  24912. report: string;
  24913. };
  24914. /** @hidden */
  24915. _checkDelayState(): Mesh;
  24916. private _queueLoad;
  24917. /**
  24918. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24919. * A mesh is in the frustum if its bounding box intersects the frustum
  24920. * @param frustumPlanes defines the frustum to test
  24921. * @returns true if the mesh is in the frustum planes
  24922. */
  24923. isInFrustum(frustumPlanes: Plane[]): boolean;
  24924. /**
  24925. * Sets the mesh material by the material or multiMaterial `id` property
  24926. * @param id is a string identifying the material or the multiMaterial
  24927. * @returns the current mesh
  24928. */
  24929. setMaterialByID(id: string): Mesh;
  24930. /**
  24931. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24932. * @returns an array of IAnimatable
  24933. */
  24934. getAnimatables(): IAnimatable[];
  24935. /**
  24936. * Modifies the mesh geometry according to the passed transformation matrix.
  24937. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24938. * The mesh normals are modified using the same transformation.
  24939. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24940. * @param transform defines the transform matrix to use
  24941. * @see http://doc.babylonjs.com/resources/baking_transformations
  24942. * @returns the current mesh
  24943. */
  24944. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24945. /**
  24946. * Modifies the mesh geometry according to its own current World Matrix.
  24947. * The mesh World Matrix is then reset.
  24948. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24949. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24950. * @see http://doc.babylonjs.com/resources/baking_transformations
  24951. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24952. * @returns the current mesh
  24953. */
  24954. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24955. /** @hidden */
  24956. get _positions(): Nullable<Vector3[]>;
  24957. /** @hidden */
  24958. _resetPointsArrayCache(): Mesh;
  24959. /** @hidden */
  24960. _generatePointsArray(): boolean;
  24961. /**
  24962. * Returns a new Mesh object generated from the current mesh properties.
  24963. * This method must not get confused with createInstance()
  24964. * @param name is a string, the name given to the new mesh
  24965. * @param newParent can be any Node object (default `null`)
  24966. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24967. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24968. * @returns a new mesh
  24969. */
  24970. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24971. /**
  24972. * Releases resources associated with this mesh.
  24973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24975. */
  24976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24977. /** @hidden */
  24978. _disposeInstanceSpecificData(): void;
  24979. /**
  24980. * Modifies the mesh geometry according to a displacement map.
  24981. * 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.
  24982. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24983. * @param url is a string, the URL from the image file is to be downloaded.
  24984. * @param minHeight is the lower limit of the displacement.
  24985. * @param maxHeight is the upper limit of the displacement.
  24986. * @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.
  24987. * @param uvOffset is an optional vector2 used to offset UV.
  24988. * @param uvScale is an optional vector2 used to scale UV.
  24989. * @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.
  24990. * @returns the Mesh.
  24991. */
  24992. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24993. /**
  24994. * Modifies the mesh geometry according to a displacementMap buffer.
  24995. * 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.
  24996. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24997. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24998. * @param heightMapWidth is the width of the buffer image.
  24999. * @param heightMapHeight is the height of the buffer image.
  25000. * @param minHeight is the lower limit of the displacement.
  25001. * @param maxHeight is the upper limit of the displacement.
  25002. * @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.
  25003. * @param uvOffset is an optional vector2 used to offset UV.
  25004. * @param uvScale is an optional vector2 used to scale UV.
  25005. * @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.
  25006. * @returns the Mesh.
  25007. */
  25008. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25009. /**
  25010. * Modify the mesh to get a flat shading rendering.
  25011. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25012. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25013. * @returns current mesh
  25014. */
  25015. convertToFlatShadedMesh(): Mesh;
  25016. /**
  25017. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25018. * In other words, more vertices, no more indices and a single bigger VBO.
  25019. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25020. * @returns current mesh
  25021. */
  25022. convertToUnIndexedMesh(): Mesh;
  25023. /**
  25024. * Inverses facet orientations.
  25025. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25026. * @param flipNormals will also inverts the normals
  25027. * @returns current mesh
  25028. */
  25029. flipFaces(flipNormals?: boolean): Mesh;
  25030. /**
  25031. * Increase the number of facets and hence vertices in a mesh
  25032. * Vertex normals are interpolated from existing vertex normals
  25033. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25034. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25035. */
  25036. increaseVertices(numberPerEdge: number): void;
  25037. /**
  25038. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25039. * This will undo any application of covertToFlatShadedMesh
  25040. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25041. */
  25042. forceSharedVertices(): void;
  25043. /** @hidden */
  25044. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25045. /** @hidden */
  25046. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25047. /**
  25048. * Creates a new InstancedMesh object from the mesh model.
  25049. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25050. * @param name defines the name of the new instance
  25051. * @returns a new InstancedMesh
  25052. */
  25053. createInstance(name: string): InstancedMesh;
  25054. /**
  25055. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25056. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25057. * @returns the current mesh
  25058. */
  25059. synchronizeInstances(): Mesh;
  25060. /**
  25061. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25062. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25063. * This should be used together with the simplification to avoid disappearing triangles.
  25064. * @param successCallback an optional success callback to be called after the optimization finished.
  25065. * @returns the current mesh
  25066. */
  25067. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25068. /**
  25069. * Serialize current mesh
  25070. * @param serializationObject defines the object which will receive the serialization data
  25071. */
  25072. serialize(serializationObject: any): void;
  25073. /** @hidden */
  25074. _syncGeometryWithMorphTargetManager(): void;
  25075. /** @hidden */
  25076. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25077. /**
  25078. * Returns a new Mesh object parsed from the source provided.
  25079. * @param parsedMesh is the source
  25080. * @param scene defines the hosting scene
  25081. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25082. * @returns a new Mesh
  25083. */
  25084. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25085. /**
  25086. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25087. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25088. * @param name defines the name of the mesh to create
  25089. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25090. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25091. * @param closePath creates a seam between the first and the last points of each path of the path array
  25092. * @param offset is taken in account only if the `pathArray` is containing a single path
  25093. * @param scene defines the hosting scene
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @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)
  25097. * @returns a new Mesh
  25098. */
  25099. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25100. /**
  25101. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25102. * @param name defines the name of the mesh to create
  25103. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25104. * @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
  25105. * @param scene defines the hosting scene
  25106. * @param updatable defines if the mesh must be flagged as updatable
  25107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25108. * @returns a new Mesh
  25109. */
  25110. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25111. /**
  25112. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25113. * @param name defines the name of the mesh to create
  25114. * @param size sets the size (float) of each box side (default 1)
  25115. * @param scene defines the hosting scene
  25116. * @param updatable defines if the mesh must be flagged as updatable
  25117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25118. * @returns a new Mesh
  25119. */
  25120. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25121. /**
  25122. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25123. * @param name defines the name of the mesh to create
  25124. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25125. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25126. * @param scene defines the hosting scene
  25127. * @param updatable defines if the mesh must be flagged as updatable
  25128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25129. * @returns a new Mesh
  25130. */
  25131. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25132. /**
  25133. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25134. * @param name defines the name of the mesh to create
  25135. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25136. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25137. * @param scene defines the hosting scene
  25138. * @returns a new Mesh
  25139. */
  25140. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25141. /**
  25142. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25143. * @param name defines the name of the mesh to create
  25144. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25145. * @param diameterTop set the top cap diameter (floats, default 1)
  25146. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25147. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25148. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25149. * @param scene defines the hosting scene
  25150. * @param updatable defines if the mesh must be flagged as updatable
  25151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25152. * @returns a new Mesh
  25153. */
  25154. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25155. /**
  25156. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25157. * @param name defines the name of the mesh to create
  25158. * @param diameter sets the diameter size (float) of the torus (default 1)
  25159. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25160. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25161. * @param scene defines the hosting scene
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25167. /**
  25168. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25171. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25172. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25173. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25174. * @param p the number of windings on X axis (positive integers, default 2)
  25175. * @param q the number of windings on Y axis (positive integers, default 3)
  25176. * @param scene defines the hosting scene
  25177. * @param updatable defines if the mesh must be flagged as updatable
  25178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25179. * @returns a new Mesh
  25180. */
  25181. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25182. /**
  25183. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25184. * @param name defines the name of the mesh to create
  25185. * @param points is an array successive Vector3
  25186. * @param scene defines the hosting scene
  25187. * @param updatable defines if the mesh must be flagged as updatable
  25188. * @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).
  25189. * @returns a new Mesh
  25190. */
  25191. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25192. /**
  25193. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25194. * @param name defines the name of the mesh to create
  25195. * @param points is an array successive Vector3
  25196. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25197. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25198. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25199. * @param scene defines the hosting scene
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @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)
  25202. * @returns a new Mesh
  25203. */
  25204. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25205. /**
  25206. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25207. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25208. * 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.
  25209. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25210. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25211. * Remember you can only change the shape positions, not their number when updating a polygon.
  25212. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25213. * @param name defines the name of the mesh to create
  25214. * @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
  25215. * @param scene defines the hosting scene
  25216. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25217. * @param updatable defines if the mesh must be flagged as updatable
  25218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25219. * @param earcutInjection can be used to inject your own earcut reference
  25220. * @returns a new Mesh
  25221. */
  25222. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25223. /**
  25224. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25225. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25226. * @param name defines the name of the mesh to create
  25227. * @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
  25228. * @param depth defines the height of extrusion
  25229. * @param scene defines the hosting scene
  25230. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25231. * @param updatable defines if the mesh must be flagged as updatable
  25232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25233. * @param earcutInjection can be used to inject your own earcut reference
  25234. * @returns a new Mesh
  25235. */
  25236. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25237. /**
  25238. * Creates an extruded shape mesh.
  25239. * 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
  25240. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25241. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25242. * @param name defines the name of the mesh to create
  25243. * @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
  25244. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25245. * @param scale is the value to scale the shape
  25246. * @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
  25247. * @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
  25248. * @param scene defines the hosting scene
  25249. * @param updatable defines if the mesh must be flagged as updatable
  25250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25251. * @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)
  25252. * @returns a new Mesh
  25253. */
  25254. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25255. /**
  25256. * Creates an custom extruded shape mesh.
  25257. * The custom extrusion is a parametric shape.
  25258. * It has no predefined shape. Its final shape will depend on the input parameters.
  25259. * Please consider using the same method from the MeshBuilder class instead
  25260. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25261. * @param name defines the name of the mesh to create
  25262. * @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
  25263. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25264. * @param scaleFunction is a custom Javascript function called on each path point
  25265. * @param rotationFunction is a custom Javascript function called on each path point
  25266. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25267. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25268. * @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
  25269. * @param scene defines the hosting scene
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25272. * @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)
  25273. * @returns a new Mesh
  25274. */
  25275. 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;
  25276. /**
  25277. * Creates lathe mesh.
  25278. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25279. * Please consider using the same method from the MeshBuilder class instead
  25280. * @param name defines the name of the mesh to create
  25281. * @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
  25282. * @param radius is the radius value of the lathe
  25283. * @param tessellation is the side number of the lathe.
  25284. * @param scene defines the hosting scene
  25285. * @param updatable defines if the mesh must be flagged as updatable
  25286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25287. * @returns a new Mesh
  25288. */
  25289. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25290. /**
  25291. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25292. * @param name defines the name of the mesh to create
  25293. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25294. * @param scene defines the hosting scene
  25295. * @param updatable defines if the mesh must be flagged as updatable
  25296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25297. * @returns a new Mesh
  25298. */
  25299. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25300. /**
  25301. * Creates a ground mesh.
  25302. * Please consider using the same method from the MeshBuilder class instead
  25303. * @param name defines the name of the mesh to create
  25304. * @param width set the width of the ground
  25305. * @param height set the height of the ground
  25306. * @param subdivisions sets the number of subdivisions per side
  25307. * @param scene defines the hosting scene
  25308. * @param updatable defines if the mesh must be flagged as updatable
  25309. * @returns a new Mesh
  25310. */
  25311. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25312. /**
  25313. * Creates a tiled ground mesh.
  25314. * Please consider using the same method from the MeshBuilder class instead
  25315. * @param name defines the name of the mesh to create
  25316. * @param xmin set the ground minimum X coordinate
  25317. * @param zmin set the ground minimum Y coordinate
  25318. * @param xmax set the ground maximum X coordinate
  25319. * @param zmax set the ground maximum Z coordinate
  25320. * @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
  25321. * @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
  25322. * @param scene defines the hosting scene
  25323. * @param updatable defines if the mesh must be flagged as updatable
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25327. w: number;
  25328. h: number;
  25329. }, precision: {
  25330. w: number;
  25331. h: number;
  25332. }, scene: Scene, updatable?: boolean): Mesh;
  25333. /**
  25334. * Creates a ground mesh from a height map.
  25335. * Please consider using the same method from the MeshBuilder class instead
  25336. * @see http://doc.babylonjs.com/babylon101/height_map
  25337. * @param name defines the name of the mesh to create
  25338. * @param url sets the URL of the height map image resource
  25339. * @param width set the ground width size
  25340. * @param height set the ground height size
  25341. * @param subdivisions sets the number of subdivision per side
  25342. * @param minHeight is the minimum altitude on the ground
  25343. * @param maxHeight is the maximum altitude on the ground
  25344. * @param scene defines the hosting scene
  25345. * @param updatable defines if the mesh must be flagged as updatable
  25346. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25347. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25348. * @returns a new Mesh
  25349. */
  25350. 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;
  25351. /**
  25352. * Creates a tube mesh.
  25353. * The tube is a parametric shape.
  25354. * It has no predefined shape. Its final shape will depend on the input parameters.
  25355. * Please consider using the same method from the MeshBuilder class instead
  25356. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25357. * @param name defines the name of the mesh to create
  25358. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25359. * @param radius sets the tube radius size
  25360. * @param tessellation is the number of sides on the tubular surface
  25361. * @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
  25362. * @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
  25363. * @param scene defines the hosting scene
  25364. * @param updatable defines if the mesh must be flagged as updatable
  25365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25366. * @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)
  25367. * @returns a new Mesh
  25368. */
  25369. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25370. (i: number, distance: number): number;
  25371. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25372. /**
  25373. * Creates a polyhedron mesh.
  25374. * Please consider using the same method from the MeshBuilder class instead.
  25375. * * 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
  25376. * * The parameter `size` (positive float, default 1) sets the polygon size
  25377. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25378. * * 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`
  25379. * * 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
  25380. * * 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)`)
  25381. * * 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
  25382. * * 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
  25383. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25384. * * 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
  25385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25386. * @param name defines the name of the mesh to create
  25387. * @param options defines the options used to create the mesh
  25388. * @param scene defines the hosting scene
  25389. * @returns a new Mesh
  25390. */
  25391. static CreatePolyhedron(name: string, options: {
  25392. type?: number;
  25393. size?: number;
  25394. sizeX?: number;
  25395. sizeY?: number;
  25396. sizeZ?: number;
  25397. custom?: any;
  25398. faceUV?: Vector4[];
  25399. faceColors?: Color4[];
  25400. updatable?: boolean;
  25401. sideOrientation?: number;
  25402. }, scene: Scene): Mesh;
  25403. /**
  25404. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25405. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25406. * * 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`)
  25407. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25408. * * 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
  25409. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25410. * * 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
  25411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25412. * @param name defines the name of the mesh
  25413. * @param options defines the options used to create the mesh
  25414. * @param scene defines the hosting scene
  25415. * @returns a new Mesh
  25416. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25417. */
  25418. static CreateIcoSphere(name: string, options: {
  25419. radius?: number;
  25420. flat?: boolean;
  25421. subdivisions?: number;
  25422. sideOrientation?: number;
  25423. updatable?: boolean;
  25424. }, scene: Scene): Mesh;
  25425. /**
  25426. * Creates a decal mesh.
  25427. * Please consider using the same method from the MeshBuilder class instead.
  25428. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25429. * @param name defines the name of the mesh
  25430. * @param sourceMesh defines the mesh receiving the decal
  25431. * @param position sets the position of the decal in world coordinates
  25432. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25433. * @param size sets the decal scaling
  25434. * @param angle sets the angle to rotate the decal
  25435. * @returns a new Mesh
  25436. */
  25437. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25438. /**
  25439. * Prepare internal position array for software CPU skinning
  25440. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25441. */
  25442. setPositionsForCPUSkinning(): Float32Array;
  25443. /**
  25444. * Prepare internal normal array for software CPU skinning
  25445. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25446. */
  25447. setNormalsForCPUSkinning(): Float32Array;
  25448. /**
  25449. * Updates the vertex buffer by applying transformation from the bones
  25450. * @param skeleton defines the skeleton to apply to current mesh
  25451. * @returns the current mesh
  25452. */
  25453. applySkeleton(skeleton: Skeleton): Mesh;
  25454. /**
  25455. * 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
  25456. * @param meshes defines the list of meshes to scan
  25457. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25458. */
  25459. static MinMax(meshes: AbstractMesh[]): {
  25460. min: Vector3;
  25461. max: Vector3;
  25462. };
  25463. /**
  25464. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25465. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25466. * @returns a vector3
  25467. */
  25468. static Center(meshesOrMinMaxVector: {
  25469. min: Vector3;
  25470. max: Vector3;
  25471. } | AbstractMesh[]): Vector3;
  25472. /**
  25473. * Merge the array of meshes into a single mesh for performance reasons.
  25474. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25475. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25476. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25477. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25478. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25479. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25480. * @returns a new mesh
  25481. */
  25482. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25483. /** @hidden */
  25484. addInstance(instance: InstancedMesh): void;
  25485. /** @hidden */
  25486. removeInstance(instance: InstancedMesh): void;
  25487. }
  25488. }
  25489. declare module BABYLON {
  25490. /**
  25491. * This is the base class of all the camera used in the application.
  25492. * @see http://doc.babylonjs.com/features/cameras
  25493. */
  25494. export class Camera extends Node {
  25495. /** @hidden */
  25496. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25497. /**
  25498. * This is the default projection mode used by the cameras.
  25499. * It helps recreating a feeling of perspective and better appreciate depth.
  25500. * This is the best way to simulate real life cameras.
  25501. */
  25502. static readonly PERSPECTIVE_CAMERA: number;
  25503. /**
  25504. * This helps creating camera with an orthographic mode.
  25505. * 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.
  25506. */
  25507. static readonly ORTHOGRAPHIC_CAMERA: number;
  25508. /**
  25509. * This is the default FOV mode for perspective cameras.
  25510. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25511. */
  25512. static readonly FOVMODE_VERTICAL_FIXED: number;
  25513. /**
  25514. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25515. */
  25516. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25517. /**
  25518. * This specifies ther is no need for a camera rig.
  25519. * Basically only one eye is rendered corresponding to the camera.
  25520. */
  25521. static readonly RIG_MODE_NONE: number;
  25522. /**
  25523. * Simulates a camera Rig with one blue eye and one red eye.
  25524. * This can be use with 3d blue and red glasses.
  25525. */
  25526. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25527. /**
  25528. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25529. */
  25530. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25531. /**
  25532. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25533. */
  25534. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25535. /**
  25536. * Defines that both eyes of the camera will be rendered over under each other.
  25537. */
  25538. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25539. /**
  25540. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25541. */
  25542. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25543. /**
  25544. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25545. */
  25546. static readonly RIG_MODE_VR: number;
  25547. /**
  25548. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25549. */
  25550. static readonly RIG_MODE_WEBVR: number;
  25551. /**
  25552. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25553. */
  25554. static readonly RIG_MODE_CUSTOM: number;
  25555. /**
  25556. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25557. */
  25558. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25559. /**
  25560. * Define the input manager associated with the camera.
  25561. */
  25562. inputs: CameraInputsManager<Camera>;
  25563. /** @hidden */
  25564. _position: Vector3;
  25565. /**
  25566. * Define the current local position of the camera in the scene
  25567. */
  25568. get position(): Vector3;
  25569. set position(newPosition: Vector3);
  25570. /**
  25571. * The vector the camera should consider as up.
  25572. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25573. */
  25574. upVector: Vector3;
  25575. /**
  25576. * Define the current limit on the left side for an orthographic camera
  25577. * In scene unit
  25578. */
  25579. orthoLeft: Nullable<number>;
  25580. /**
  25581. * Define the current limit on the right side for an orthographic camera
  25582. * In scene unit
  25583. */
  25584. orthoRight: Nullable<number>;
  25585. /**
  25586. * Define the current limit on the bottom side for an orthographic camera
  25587. * In scene unit
  25588. */
  25589. orthoBottom: Nullable<number>;
  25590. /**
  25591. * Define the current limit on the top side for an orthographic camera
  25592. * In scene unit
  25593. */
  25594. orthoTop: Nullable<number>;
  25595. /**
  25596. * Field Of View is set in Radians. (default is 0.8)
  25597. */
  25598. fov: number;
  25599. /**
  25600. * Define the minimum distance the camera can see from.
  25601. * This is important to note that the depth buffer are not infinite and the closer it starts
  25602. * the more your scene might encounter depth fighting issue.
  25603. */
  25604. minZ: number;
  25605. /**
  25606. * Define the maximum distance the camera can see to.
  25607. * This is important to note that the depth buffer are not infinite and the further it end
  25608. * the more your scene might encounter depth fighting issue.
  25609. */
  25610. maxZ: number;
  25611. /**
  25612. * Define the default inertia of the camera.
  25613. * This helps giving a smooth feeling to the camera movement.
  25614. */
  25615. inertia: number;
  25616. /**
  25617. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25618. */
  25619. mode: number;
  25620. /**
  25621. * Define whether the camera is intermediate.
  25622. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25623. */
  25624. isIntermediate: boolean;
  25625. /**
  25626. * Define the viewport of the camera.
  25627. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25628. */
  25629. viewport: Viewport;
  25630. /**
  25631. * Restricts the camera to viewing objects with the same layerMask.
  25632. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25633. */
  25634. layerMask: number;
  25635. /**
  25636. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25637. */
  25638. fovMode: number;
  25639. /**
  25640. * Rig mode of the camera.
  25641. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25642. * This is normally controlled byt the camera themselves as internal use.
  25643. */
  25644. cameraRigMode: number;
  25645. /**
  25646. * Defines the distance between both "eyes" in case of a RIG
  25647. */
  25648. interaxialDistance: number;
  25649. /**
  25650. * Defines if stereoscopic rendering is done side by side or over under.
  25651. */
  25652. isStereoscopicSideBySide: boolean;
  25653. /**
  25654. * 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
  25655. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25656. * else in the scene. (Eg. security camera)
  25657. *
  25658. * 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)
  25659. */
  25660. customRenderTargets: RenderTargetTexture[];
  25661. /**
  25662. * When set, the camera will render to this render target instead of the default canvas
  25663. *
  25664. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25665. */
  25666. outputRenderTarget: Nullable<RenderTargetTexture>;
  25667. /**
  25668. * Observable triggered when the camera view matrix has changed.
  25669. */
  25670. onViewMatrixChangedObservable: Observable<Camera>;
  25671. /**
  25672. * Observable triggered when the camera Projection matrix has changed.
  25673. */
  25674. onProjectionMatrixChangedObservable: Observable<Camera>;
  25675. /**
  25676. * Observable triggered when the inputs have been processed.
  25677. */
  25678. onAfterCheckInputsObservable: Observable<Camera>;
  25679. /**
  25680. * Observable triggered when reset has been called and applied to the camera.
  25681. */
  25682. onRestoreStateObservable: Observable<Camera>;
  25683. /**
  25684. * Is this camera a part of a rig system?
  25685. */
  25686. isRigCamera: boolean;
  25687. /**
  25688. * If isRigCamera set to true this will be set with the parent camera.
  25689. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25690. */
  25691. rigParent?: Camera;
  25692. /** @hidden */
  25693. _cameraRigParams: any;
  25694. /** @hidden */
  25695. _rigCameras: Camera[];
  25696. /** @hidden */
  25697. _rigPostProcess: Nullable<PostProcess>;
  25698. protected _webvrViewMatrix: Matrix;
  25699. /** @hidden */
  25700. _skipRendering: boolean;
  25701. /** @hidden */
  25702. _projectionMatrix: Matrix;
  25703. /** @hidden */
  25704. _postProcesses: Nullable<PostProcess>[];
  25705. /** @hidden */
  25706. _activeMeshes: SmartArray<AbstractMesh>;
  25707. protected _globalPosition: Vector3;
  25708. /** @hidden */
  25709. _computedViewMatrix: Matrix;
  25710. private _doNotComputeProjectionMatrix;
  25711. private _transformMatrix;
  25712. private _frustumPlanes;
  25713. private _refreshFrustumPlanes;
  25714. private _storedFov;
  25715. private _stateStored;
  25716. /**
  25717. * Instantiates a new camera object.
  25718. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25719. * @see http://doc.babylonjs.com/features/cameras
  25720. * @param name Defines the name of the camera in the scene
  25721. * @param position Defines the position of the camera
  25722. * @param scene Defines the scene the camera belongs too
  25723. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25724. */
  25725. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25726. /**
  25727. * Store current camera state (fov, position, etc..)
  25728. * @returns the camera
  25729. */
  25730. storeState(): Camera;
  25731. /**
  25732. * Restores the camera state values if it has been stored. You must call storeState() first
  25733. */
  25734. protected _restoreStateValues(): boolean;
  25735. /**
  25736. * Restored camera state. You must call storeState() first.
  25737. * @returns true if restored and false otherwise
  25738. */
  25739. restoreState(): boolean;
  25740. /**
  25741. * Gets the class name of the camera.
  25742. * @returns the class name
  25743. */
  25744. getClassName(): string;
  25745. /** @hidden */
  25746. readonly _isCamera: boolean;
  25747. /**
  25748. * Gets a string representation of the camera useful for debug purpose.
  25749. * @param fullDetails Defines that a more verboe level of logging is required
  25750. * @returns the string representation
  25751. */
  25752. toString(fullDetails?: boolean): string;
  25753. /**
  25754. * Gets the current world space position of the camera.
  25755. */
  25756. get globalPosition(): Vector3;
  25757. /**
  25758. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25759. * @returns the active meshe list
  25760. */
  25761. getActiveMeshes(): SmartArray<AbstractMesh>;
  25762. /**
  25763. * Check whether a mesh is part of the current active mesh list of the camera
  25764. * @param mesh Defines the mesh to check
  25765. * @returns true if active, false otherwise
  25766. */
  25767. isActiveMesh(mesh: Mesh): boolean;
  25768. /**
  25769. * Is this camera ready to be used/rendered
  25770. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25771. * @return true if the camera is ready
  25772. */
  25773. isReady(completeCheck?: boolean): boolean;
  25774. /** @hidden */
  25775. _initCache(): void;
  25776. /** @hidden */
  25777. _updateCache(ignoreParentClass?: boolean): void;
  25778. /** @hidden */
  25779. _isSynchronized(): boolean;
  25780. /** @hidden */
  25781. _isSynchronizedViewMatrix(): boolean;
  25782. /** @hidden */
  25783. _isSynchronizedProjectionMatrix(): boolean;
  25784. /**
  25785. * Attach the input controls to a specific dom element to get the input from.
  25786. * @param element Defines the element the controls should be listened from
  25787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25788. */
  25789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25790. /**
  25791. * Detach the current controls from the specified dom element.
  25792. * @param element Defines the element to stop listening the inputs from
  25793. */
  25794. detachControl(element: HTMLElement): void;
  25795. /**
  25796. * Update the camera state according to the different inputs gathered during the frame.
  25797. */
  25798. update(): void;
  25799. /** @hidden */
  25800. _checkInputs(): void;
  25801. /** @hidden */
  25802. get rigCameras(): Camera[];
  25803. /**
  25804. * Gets the post process used by the rig cameras
  25805. */
  25806. get rigPostProcess(): Nullable<PostProcess>;
  25807. /**
  25808. * Internal, gets the first post proces.
  25809. * @returns the first post process to be run on this camera.
  25810. */
  25811. _getFirstPostProcess(): Nullable<PostProcess>;
  25812. private _cascadePostProcessesToRigCams;
  25813. /**
  25814. * Attach a post process to the camera.
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25816. * @param postProcess The post process to attach to the camera
  25817. * @param insertAt The position of the post process in case several of them are in use in the scene
  25818. * @returns the position the post process has been inserted at
  25819. */
  25820. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25821. /**
  25822. * Detach a post process to the camera.
  25823. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25824. * @param postProcess The post process to detach from the camera
  25825. */
  25826. detachPostProcess(postProcess: PostProcess): void;
  25827. /**
  25828. * Gets the current world matrix of the camera
  25829. */
  25830. getWorldMatrix(): Matrix;
  25831. /** @hidden */
  25832. _getViewMatrix(): Matrix;
  25833. /**
  25834. * Gets the current view matrix of the camera.
  25835. * @param force forces the camera to recompute the matrix without looking at the cached state
  25836. * @returns the view matrix
  25837. */
  25838. getViewMatrix(force?: boolean): Matrix;
  25839. /**
  25840. * Freeze the projection matrix.
  25841. * It will prevent the cache check of the camera projection compute and can speed up perf
  25842. * if no parameter of the camera are meant to change
  25843. * @param projection Defines manually a projection if necessary
  25844. */
  25845. freezeProjectionMatrix(projection?: Matrix): void;
  25846. /**
  25847. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25848. */
  25849. unfreezeProjectionMatrix(): void;
  25850. /**
  25851. * Gets the current projection matrix of the camera.
  25852. * @param force forces the camera to recompute the matrix without looking at the cached state
  25853. * @returns the projection matrix
  25854. */
  25855. getProjectionMatrix(force?: boolean): Matrix;
  25856. /**
  25857. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25858. * @returns a Matrix
  25859. */
  25860. getTransformationMatrix(): Matrix;
  25861. private _updateFrustumPlanes;
  25862. /**
  25863. * Checks if a cullable object (mesh...) is in the camera frustum
  25864. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25865. * @param target The object to check
  25866. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25867. * @returns true if the object is in frustum otherwise false
  25868. */
  25869. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25870. /**
  25871. * Checks if a cullable object (mesh...) is in the camera frustum
  25872. * Unlike isInFrustum this cheks the full bounding box
  25873. * @param target The object to check
  25874. * @returns true if the object is in frustum otherwise false
  25875. */
  25876. isCompletelyInFrustum(target: ICullable): boolean;
  25877. /**
  25878. * Gets a ray in the forward direction from the camera.
  25879. * @param length Defines the length of the ray to create
  25880. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25881. * @param origin Defines the start point of the ray which defaults to the camera position
  25882. * @returns the forward ray
  25883. */
  25884. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25885. /**
  25886. * Releases resources associated with this node.
  25887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25889. */
  25890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25891. /** @hidden */
  25892. _isLeftCamera: boolean;
  25893. /**
  25894. * Gets the left camera of a rig setup in case of Rigged Camera
  25895. */
  25896. get isLeftCamera(): boolean;
  25897. /** @hidden */
  25898. _isRightCamera: boolean;
  25899. /**
  25900. * Gets the right camera of a rig setup in case of Rigged Camera
  25901. */
  25902. get isRightCamera(): boolean;
  25903. /**
  25904. * Gets the left camera of a rig setup in case of Rigged Camera
  25905. */
  25906. get leftCamera(): Nullable<FreeCamera>;
  25907. /**
  25908. * Gets the right camera of a rig setup in case of Rigged Camera
  25909. */
  25910. get rightCamera(): Nullable<FreeCamera>;
  25911. /**
  25912. * Gets the left camera target of a rig setup in case of Rigged Camera
  25913. * @returns the target position
  25914. */
  25915. getLeftTarget(): Nullable<Vector3>;
  25916. /**
  25917. * Gets the right camera target of a rig setup in case of Rigged Camera
  25918. * @returns the target position
  25919. */
  25920. getRightTarget(): Nullable<Vector3>;
  25921. /**
  25922. * @hidden
  25923. */
  25924. setCameraRigMode(mode: number, rigParams: any): void;
  25925. /** @hidden */
  25926. static _setStereoscopicRigMode(camera: Camera): void;
  25927. /** @hidden */
  25928. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25929. /** @hidden */
  25930. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25931. /** @hidden */
  25932. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25933. /** @hidden */
  25934. _getVRProjectionMatrix(): Matrix;
  25935. protected _updateCameraRotationMatrix(): void;
  25936. protected _updateWebVRCameraRotationMatrix(): void;
  25937. /**
  25938. * This function MUST be overwritten by the different WebVR cameras available.
  25939. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25940. * @hidden
  25941. */
  25942. _getWebVRProjectionMatrix(): Matrix;
  25943. /**
  25944. * This function MUST be overwritten by the different WebVR cameras available.
  25945. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25946. * @hidden
  25947. */
  25948. _getWebVRViewMatrix(): Matrix;
  25949. /** @hidden */
  25950. setCameraRigParameter(name: string, value: any): void;
  25951. /**
  25952. * needs to be overridden by children so sub has required properties to be copied
  25953. * @hidden
  25954. */
  25955. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25956. /**
  25957. * May need to be overridden by children
  25958. * @hidden
  25959. */
  25960. _updateRigCameras(): void;
  25961. /** @hidden */
  25962. _setupInputs(): void;
  25963. /**
  25964. * Serialiaze the camera setup to a json represention
  25965. * @returns the JSON representation
  25966. */
  25967. serialize(): any;
  25968. /**
  25969. * Clones the current camera.
  25970. * @param name The cloned camera name
  25971. * @returns the cloned camera
  25972. */
  25973. clone(name: string): Camera;
  25974. /**
  25975. * Gets the direction of the camera relative to a given local axis.
  25976. * @param localAxis Defines the reference axis to provide a relative direction.
  25977. * @return the direction
  25978. */
  25979. getDirection(localAxis: Vector3): Vector3;
  25980. /**
  25981. * Returns the current camera absolute rotation
  25982. */
  25983. get absoluteRotation(): Quaternion;
  25984. /**
  25985. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25986. * @param localAxis Defines the reference axis to provide a relative direction.
  25987. * @param result Defines the vector to store the result in
  25988. */
  25989. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25990. /**
  25991. * Gets a camera constructor for a given camera type
  25992. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25993. * @param name The name of the camera the result will be able to instantiate
  25994. * @param scene The scene the result will construct the camera in
  25995. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25996. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25997. * @returns a factory method to construc the camera
  25998. */
  25999. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26000. /**
  26001. * Compute the world matrix of the camera.
  26002. * @returns the camera world matrix
  26003. */
  26004. computeWorldMatrix(): Matrix;
  26005. /**
  26006. * Parse a JSON and creates the camera from the parsed information
  26007. * @param parsedCamera The JSON to parse
  26008. * @param scene The scene to instantiate the camera in
  26009. * @returns the newly constructed camera
  26010. */
  26011. static Parse(parsedCamera: any, scene: Scene): Camera;
  26012. }
  26013. }
  26014. declare module BABYLON {
  26015. /**
  26016. * Class containing static functions to help procedurally build meshes
  26017. */
  26018. export class DiscBuilder {
  26019. /**
  26020. * Creates a plane polygonal mesh. By default, this is a disc
  26021. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26022. * * 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
  26023. * * 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
  26024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26025. * * 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
  26026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26027. * @param name defines the name of the mesh
  26028. * @param options defines the options used to create the mesh
  26029. * @param scene defines the hosting scene
  26030. * @returns the plane polygonal mesh
  26031. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26032. */
  26033. static CreateDisc(name: string, options: {
  26034. radius?: number;
  26035. tessellation?: number;
  26036. arc?: number;
  26037. updatable?: boolean;
  26038. sideOrientation?: number;
  26039. frontUVs?: Vector4;
  26040. backUVs?: Vector4;
  26041. }, scene?: Nullable<Scene>): Mesh;
  26042. }
  26043. }
  26044. declare module BABYLON {
  26045. /**
  26046. * This represents all the required information to add a fresnel effect on a material:
  26047. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26048. */
  26049. export class FresnelParameters {
  26050. private _isEnabled;
  26051. /**
  26052. * Define if the fresnel effect is enable or not.
  26053. */
  26054. get isEnabled(): boolean;
  26055. set isEnabled(value: boolean);
  26056. /**
  26057. * Define the color used on edges (grazing angle)
  26058. */
  26059. leftColor: Color3;
  26060. /**
  26061. * Define the color used on center
  26062. */
  26063. rightColor: Color3;
  26064. /**
  26065. * Define bias applied to computed fresnel term
  26066. */
  26067. bias: number;
  26068. /**
  26069. * Defined the power exponent applied to fresnel term
  26070. */
  26071. power: number;
  26072. /**
  26073. * Clones the current fresnel and its valuues
  26074. * @returns a clone fresnel configuration
  26075. */
  26076. clone(): FresnelParameters;
  26077. /**
  26078. * Serializes the current fresnel parameters to a JSON representation.
  26079. * @return the JSON serialization
  26080. */
  26081. serialize(): any;
  26082. /**
  26083. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26084. * @param parsedFresnelParameters Define the JSON representation
  26085. * @returns the parsed parameters
  26086. */
  26087. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26088. }
  26089. }
  26090. declare module BABYLON {
  26091. /**
  26092. * Base class of materials working in push mode in babylon JS
  26093. * @hidden
  26094. */
  26095. export class PushMaterial extends Material {
  26096. protected _activeEffect: Effect;
  26097. protected _normalMatrix: Matrix;
  26098. /**
  26099. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26100. * This means that the material can keep using a previous shader while a new one is being compiled.
  26101. * This is mostly used when shader parallel compilation is supported (true by default)
  26102. */
  26103. allowShaderHotSwapping: boolean;
  26104. constructor(name: string, scene: Scene);
  26105. getEffect(): Effect;
  26106. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26107. /**
  26108. * Binds the given world matrix to the active effect
  26109. *
  26110. * @param world the matrix to bind
  26111. */
  26112. bindOnlyWorldMatrix(world: Matrix): void;
  26113. /**
  26114. * Binds the given normal matrix to the active effect
  26115. *
  26116. * @param normalMatrix the matrix to bind
  26117. */
  26118. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26119. bind(world: Matrix, mesh?: Mesh): void;
  26120. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26121. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26122. }
  26123. }
  26124. declare module BABYLON {
  26125. /**
  26126. * This groups all the flags used to control the materials channel.
  26127. */
  26128. export class MaterialFlags {
  26129. private static _DiffuseTextureEnabled;
  26130. /**
  26131. * Are diffuse textures enabled in the application.
  26132. */
  26133. static get DiffuseTextureEnabled(): boolean;
  26134. static set DiffuseTextureEnabled(value: boolean);
  26135. private static _AmbientTextureEnabled;
  26136. /**
  26137. * Are ambient textures enabled in the application.
  26138. */
  26139. static get AmbientTextureEnabled(): boolean;
  26140. static set AmbientTextureEnabled(value: boolean);
  26141. private static _OpacityTextureEnabled;
  26142. /**
  26143. * Are opacity textures enabled in the application.
  26144. */
  26145. static get OpacityTextureEnabled(): boolean;
  26146. static set OpacityTextureEnabled(value: boolean);
  26147. private static _ReflectionTextureEnabled;
  26148. /**
  26149. * Are reflection textures enabled in the application.
  26150. */
  26151. static get ReflectionTextureEnabled(): boolean;
  26152. static set ReflectionTextureEnabled(value: boolean);
  26153. private static _EmissiveTextureEnabled;
  26154. /**
  26155. * Are emissive textures enabled in the application.
  26156. */
  26157. static get EmissiveTextureEnabled(): boolean;
  26158. static set EmissiveTextureEnabled(value: boolean);
  26159. private static _SpecularTextureEnabled;
  26160. /**
  26161. * Are specular textures enabled in the application.
  26162. */
  26163. static get SpecularTextureEnabled(): boolean;
  26164. static set SpecularTextureEnabled(value: boolean);
  26165. private static _BumpTextureEnabled;
  26166. /**
  26167. * Are bump textures enabled in the application.
  26168. */
  26169. static get BumpTextureEnabled(): boolean;
  26170. static set BumpTextureEnabled(value: boolean);
  26171. private static _LightmapTextureEnabled;
  26172. /**
  26173. * Are lightmap textures enabled in the application.
  26174. */
  26175. static get LightmapTextureEnabled(): boolean;
  26176. static set LightmapTextureEnabled(value: boolean);
  26177. private static _RefractionTextureEnabled;
  26178. /**
  26179. * Are refraction textures enabled in the application.
  26180. */
  26181. static get RefractionTextureEnabled(): boolean;
  26182. static set RefractionTextureEnabled(value: boolean);
  26183. private static _ColorGradingTextureEnabled;
  26184. /**
  26185. * Are color grading textures enabled in the application.
  26186. */
  26187. static get ColorGradingTextureEnabled(): boolean;
  26188. static set ColorGradingTextureEnabled(value: boolean);
  26189. private static _FresnelEnabled;
  26190. /**
  26191. * Are fresnels enabled in the application.
  26192. */
  26193. static get FresnelEnabled(): boolean;
  26194. static set FresnelEnabled(value: boolean);
  26195. private static _ClearCoatTextureEnabled;
  26196. /**
  26197. * Are clear coat textures enabled in the application.
  26198. */
  26199. static get ClearCoatTextureEnabled(): boolean;
  26200. static set ClearCoatTextureEnabled(value: boolean);
  26201. private static _ClearCoatBumpTextureEnabled;
  26202. /**
  26203. * Are clear coat bump textures enabled in the application.
  26204. */
  26205. static get ClearCoatBumpTextureEnabled(): boolean;
  26206. static set ClearCoatBumpTextureEnabled(value: boolean);
  26207. private static _ClearCoatTintTextureEnabled;
  26208. /**
  26209. * Are clear coat tint textures enabled in the application.
  26210. */
  26211. static get ClearCoatTintTextureEnabled(): boolean;
  26212. static set ClearCoatTintTextureEnabled(value: boolean);
  26213. private static _SheenTextureEnabled;
  26214. /**
  26215. * Are sheen textures enabled in the application.
  26216. */
  26217. static get SheenTextureEnabled(): boolean;
  26218. static set SheenTextureEnabled(value: boolean);
  26219. private static _AnisotropicTextureEnabled;
  26220. /**
  26221. * Are anisotropic textures enabled in the application.
  26222. */
  26223. static get AnisotropicTextureEnabled(): boolean;
  26224. static set AnisotropicTextureEnabled(value: boolean);
  26225. private static _ThicknessTextureEnabled;
  26226. /**
  26227. * Are thickness textures enabled in the application.
  26228. */
  26229. static get ThicknessTextureEnabled(): boolean;
  26230. static set ThicknessTextureEnabled(value: boolean);
  26231. }
  26232. }
  26233. declare module BABYLON {
  26234. /** @hidden */
  26235. export var defaultFragmentDeclaration: {
  26236. name: string;
  26237. shader: string;
  26238. };
  26239. }
  26240. declare module BABYLON {
  26241. /** @hidden */
  26242. export var defaultUboDeclaration: {
  26243. name: string;
  26244. shader: string;
  26245. };
  26246. }
  26247. declare module BABYLON {
  26248. /** @hidden */
  26249. export var lightFragmentDeclaration: {
  26250. name: string;
  26251. shader: string;
  26252. };
  26253. }
  26254. declare module BABYLON {
  26255. /** @hidden */
  26256. export var lightUboDeclaration: {
  26257. name: string;
  26258. shader: string;
  26259. };
  26260. }
  26261. declare module BABYLON {
  26262. /** @hidden */
  26263. export var lightsFragmentFunctions: {
  26264. name: string;
  26265. shader: string;
  26266. };
  26267. }
  26268. declare module BABYLON {
  26269. /** @hidden */
  26270. export var shadowsFragmentFunctions: {
  26271. name: string;
  26272. shader: string;
  26273. };
  26274. }
  26275. declare module BABYLON {
  26276. /** @hidden */
  26277. export var fresnelFunction: {
  26278. name: string;
  26279. shader: string;
  26280. };
  26281. }
  26282. declare module BABYLON {
  26283. /** @hidden */
  26284. export var reflectionFunction: {
  26285. name: string;
  26286. shader: string;
  26287. };
  26288. }
  26289. declare module BABYLON {
  26290. /** @hidden */
  26291. export var bumpFragmentFunctions: {
  26292. name: string;
  26293. shader: string;
  26294. };
  26295. }
  26296. declare module BABYLON {
  26297. /** @hidden */
  26298. export var logDepthDeclaration: {
  26299. name: string;
  26300. shader: string;
  26301. };
  26302. }
  26303. declare module BABYLON {
  26304. /** @hidden */
  26305. export var bumpFragment: {
  26306. name: string;
  26307. shader: string;
  26308. };
  26309. }
  26310. declare module BABYLON {
  26311. /** @hidden */
  26312. export var depthPrePass: {
  26313. name: string;
  26314. shader: string;
  26315. };
  26316. }
  26317. declare module BABYLON {
  26318. /** @hidden */
  26319. export var lightFragment: {
  26320. name: string;
  26321. shader: string;
  26322. };
  26323. }
  26324. declare module BABYLON {
  26325. /** @hidden */
  26326. export var logDepthFragment: {
  26327. name: string;
  26328. shader: string;
  26329. };
  26330. }
  26331. declare module BABYLON {
  26332. /** @hidden */
  26333. export var defaultPixelShader: {
  26334. name: string;
  26335. shader: string;
  26336. };
  26337. }
  26338. declare module BABYLON {
  26339. /** @hidden */
  26340. export var defaultVertexDeclaration: {
  26341. name: string;
  26342. shader: string;
  26343. };
  26344. }
  26345. declare module BABYLON {
  26346. /** @hidden */
  26347. export var bumpVertexDeclaration: {
  26348. name: string;
  26349. shader: string;
  26350. };
  26351. }
  26352. declare module BABYLON {
  26353. /** @hidden */
  26354. export var bumpVertex: {
  26355. name: string;
  26356. shader: string;
  26357. };
  26358. }
  26359. declare module BABYLON {
  26360. /** @hidden */
  26361. export var fogVertex: {
  26362. name: string;
  26363. shader: string;
  26364. };
  26365. }
  26366. declare module BABYLON {
  26367. /** @hidden */
  26368. export var shadowsVertex: {
  26369. name: string;
  26370. shader: string;
  26371. };
  26372. }
  26373. declare module BABYLON {
  26374. /** @hidden */
  26375. export var pointCloudVertex: {
  26376. name: string;
  26377. shader: string;
  26378. };
  26379. }
  26380. declare module BABYLON {
  26381. /** @hidden */
  26382. export var logDepthVertex: {
  26383. name: string;
  26384. shader: string;
  26385. };
  26386. }
  26387. declare module BABYLON {
  26388. /** @hidden */
  26389. export var defaultVertexShader: {
  26390. name: string;
  26391. shader: string;
  26392. };
  26393. }
  26394. declare module BABYLON {
  26395. /** @hidden */
  26396. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26397. MAINUV1: boolean;
  26398. MAINUV2: boolean;
  26399. DIFFUSE: boolean;
  26400. DIFFUSEDIRECTUV: number;
  26401. AMBIENT: boolean;
  26402. AMBIENTDIRECTUV: number;
  26403. OPACITY: boolean;
  26404. OPACITYDIRECTUV: number;
  26405. OPACITYRGB: boolean;
  26406. REFLECTION: boolean;
  26407. EMISSIVE: boolean;
  26408. EMISSIVEDIRECTUV: number;
  26409. SPECULAR: boolean;
  26410. SPECULARDIRECTUV: number;
  26411. BUMP: boolean;
  26412. BUMPDIRECTUV: number;
  26413. PARALLAX: boolean;
  26414. PARALLAXOCCLUSION: boolean;
  26415. SPECULAROVERALPHA: boolean;
  26416. CLIPPLANE: boolean;
  26417. CLIPPLANE2: boolean;
  26418. CLIPPLANE3: boolean;
  26419. CLIPPLANE4: boolean;
  26420. CLIPPLANE5: boolean;
  26421. CLIPPLANE6: boolean;
  26422. ALPHATEST: boolean;
  26423. DEPTHPREPASS: boolean;
  26424. ALPHAFROMDIFFUSE: boolean;
  26425. POINTSIZE: boolean;
  26426. FOG: boolean;
  26427. SPECULARTERM: boolean;
  26428. DIFFUSEFRESNEL: boolean;
  26429. OPACITYFRESNEL: boolean;
  26430. REFLECTIONFRESNEL: boolean;
  26431. REFRACTIONFRESNEL: boolean;
  26432. EMISSIVEFRESNEL: boolean;
  26433. FRESNEL: boolean;
  26434. NORMAL: boolean;
  26435. UV1: boolean;
  26436. UV2: boolean;
  26437. VERTEXCOLOR: boolean;
  26438. VERTEXALPHA: boolean;
  26439. NUM_BONE_INFLUENCERS: number;
  26440. BonesPerMesh: number;
  26441. BONETEXTURE: boolean;
  26442. INSTANCES: boolean;
  26443. GLOSSINESS: boolean;
  26444. ROUGHNESS: boolean;
  26445. EMISSIVEASILLUMINATION: boolean;
  26446. LINKEMISSIVEWITHDIFFUSE: boolean;
  26447. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26448. LIGHTMAP: boolean;
  26449. LIGHTMAPDIRECTUV: number;
  26450. OBJECTSPACE_NORMALMAP: boolean;
  26451. USELIGHTMAPASSHADOWMAP: boolean;
  26452. REFLECTIONMAP_3D: boolean;
  26453. REFLECTIONMAP_SPHERICAL: boolean;
  26454. REFLECTIONMAP_PLANAR: boolean;
  26455. REFLECTIONMAP_CUBIC: boolean;
  26456. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26457. REFLECTIONMAP_PROJECTION: boolean;
  26458. REFLECTIONMAP_SKYBOX: boolean;
  26459. REFLECTIONMAP_EXPLICIT: boolean;
  26460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26463. INVERTCUBICMAP: boolean;
  26464. LOGARITHMICDEPTH: boolean;
  26465. REFRACTION: boolean;
  26466. REFRACTIONMAP_3D: boolean;
  26467. REFLECTIONOVERALPHA: boolean;
  26468. TWOSIDEDLIGHTING: boolean;
  26469. SHADOWFLOAT: boolean;
  26470. MORPHTARGETS: boolean;
  26471. MORPHTARGETS_NORMAL: boolean;
  26472. MORPHTARGETS_TANGENT: boolean;
  26473. MORPHTARGETS_UV: boolean;
  26474. NUM_MORPH_INFLUENCERS: number;
  26475. NONUNIFORMSCALING: boolean;
  26476. PREMULTIPLYALPHA: boolean;
  26477. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26478. ALPHABLEND: boolean;
  26479. IMAGEPROCESSING: boolean;
  26480. VIGNETTE: boolean;
  26481. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26482. VIGNETTEBLENDMODEOPAQUE: boolean;
  26483. TONEMAPPING: boolean;
  26484. TONEMAPPING_ACES: boolean;
  26485. CONTRAST: boolean;
  26486. COLORCURVES: boolean;
  26487. COLORGRADING: boolean;
  26488. COLORGRADING3D: boolean;
  26489. SAMPLER3DGREENDEPTH: boolean;
  26490. SAMPLER3DBGRMAP: boolean;
  26491. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26492. MULTIVIEW: boolean;
  26493. /**
  26494. * If the reflection texture on this material is in linear color space
  26495. * @hidden
  26496. */
  26497. IS_REFLECTION_LINEAR: boolean;
  26498. /**
  26499. * If the refraction texture on this material is in linear color space
  26500. * @hidden
  26501. */
  26502. IS_REFRACTION_LINEAR: boolean;
  26503. EXPOSURE: boolean;
  26504. constructor();
  26505. setReflectionMode(modeToEnable: string): void;
  26506. }
  26507. /**
  26508. * This is the default material used in Babylon. It is the best trade off between quality
  26509. * and performances.
  26510. * @see http://doc.babylonjs.com/babylon101/materials
  26511. */
  26512. export class StandardMaterial extends PushMaterial {
  26513. private _diffuseTexture;
  26514. /**
  26515. * The basic texture of the material as viewed under a light.
  26516. */
  26517. diffuseTexture: Nullable<BaseTexture>;
  26518. private _ambientTexture;
  26519. /**
  26520. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26521. */
  26522. ambientTexture: Nullable<BaseTexture>;
  26523. private _opacityTexture;
  26524. /**
  26525. * Define the transparency of the material from a texture.
  26526. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26527. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26528. */
  26529. opacityTexture: Nullable<BaseTexture>;
  26530. private _reflectionTexture;
  26531. /**
  26532. * Define the texture used to display the reflection.
  26533. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26534. */
  26535. reflectionTexture: Nullable<BaseTexture>;
  26536. private _emissiveTexture;
  26537. /**
  26538. * Define texture of the material as if self lit.
  26539. * This will be mixed in the final result even in the absence of light.
  26540. */
  26541. emissiveTexture: Nullable<BaseTexture>;
  26542. private _specularTexture;
  26543. /**
  26544. * Define how the color and intensity of the highlight given by the light in the material.
  26545. */
  26546. specularTexture: Nullable<BaseTexture>;
  26547. private _bumpTexture;
  26548. /**
  26549. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26550. * 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.
  26551. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26552. */
  26553. bumpTexture: Nullable<BaseTexture>;
  26554. private _lightmapTexture;
  26555. /**
  26556. * Complex lighting can be computationally expensive to compute at runtime.
  26557. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26558. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26559. */
  26560. lightmapTexture: Nullable<BaseTexture>;
  26561. private _refractionTexture;
  26562. /**
  26563. * Define the texture used to display the refraction.
  26564. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26565. */
  26566. refractionTexture: Nullable<BaseTexture>;
  26567. /**
  26568. * The color of the material lit by the environmental background lighting.
  26569. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26570. */
  26571. ambientColor: Color3;
  26572. /**
  26573. * The basic color of the material as viewed under a light.
  26574. */
  26575. diffuseColor: Color3;
  26576. /**
  26577. * Define how the color and intensity of the highlight given by the light in the material.
  26578. */
  26579. specularColor: Color3;
  26580. /**
  26581. * Define the color of the material as if self lit.
  26582. * This will be mixed in the final result even in the absence of light.
  26583. */
  26584. emissiveColor: Color3;
  26585. /**
  26586. * Defines how sharp are the highlights in the material.
  26587. * The bigger the value the sharper giving a more glossy feeling to the result.
  26588. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26589. */
  26590. specularPower: number;
  26591. private _useAlphaFromDiffuseTexture;
  26592. /**
  26593. * Does the transparency come from the diffuse texture alpha channel.
  26594. */
  26595. useAlphaFromDiffuseTexture: boolean;
  26596. private _useEmissiveAsIllumination;
  26597. /**
  26598. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26599. */
  26600. useEmissiveAsIllumination: boolean;
  26601. private _linkEmissiveWithDiffuse;
  26602. /**
  26603. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26604. * the emissive level when the final color is close to one.
  26605. */
  26606. linkEmissiveWithDiffuse: boolean;
  26607. private _useSpecularOverAlpha;
  26608. /**
  26609. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26610. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26611. */
  26612. useSpecularOverAlpha: boolean;
  26613. private _useReflectionOverAlpha;
  26614. /**
  26615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26617. */
  26618. useReflectionOverAlpha: boolean;
  26619. private _disableLighting;
  26620. /**
  26621. * Does lights from the scene impacts this material.
  26622. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26623. */
  26624. disableLighting: boolean;
  26625. private _useObjectSpaceNormalMap;
  26626. /**
  26627. * Allows using an object space normal map (instead of tangent space).
  26628. */
  26629. useObjectSpaceNormalMap: boolean;
  26630. private _useParallax;
  26631. /**
  26632. * Is parallax enabled or not.
  26633. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26634. */
  26635. useParallax: boolean;
  26636. private _useParallaxOcclusion;
  26637. /**
  26638. * Is parallax occlusion enabled or not.
  26639. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26640. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26641. */
  26642. useParallaxOcclusion: boolean;
  26643. /**
  26644. * 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.
  26645. */
  26646. parallaxScaleBias: number;
  26647. private _roughness;
  26648. /**
  26649. * Helps to define how blurry the reflections should appears in the material.
  26650. */
  26651. roughness: number;
  26652. /**
  26653. * In case of refraction, define the value of the index of refraction.
  26654. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26655. */
  26656. indexOfRefraction: number;
  26657. /**
  26658. * Invert the refraction texture alongside the y axis.
  26659. * It can be useful with procedural textures or probe for instance.
  26660. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26661. */
  26662. invertRefractionY: boolean;
  26663. /**
  26664. * Defines the alpha limits in alpha test mode.
  26665. */
  26666. alphaCutOff: number;
  26667. private _useLightmapAsShadowmap;
  26668. /**
  26669. * In case of light mapping, define whether the map contains light or shadow informations.
  26670. */
  26671. useLightmapAsShadowmap: boolean;
  26672. private _diffuseFresnelParameters;
  26673. /**
  26674. * Define the diffuse fresnel parameters of the material.
  26675. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26676. */
  26677. diffuseFresnelParameters: FresnelParameters;
  26678. private _opacityFresnelParameters;
  26679. /**
  26680. * Define the opacity fresnel parameters of the material.
  26681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26682. */
  26683. opacityFresnelParameters: FresnelParameters;
  26684. private _reflectionFresnelParameters;
  26685. /**
  26686. * Define the reflection fresnel parameters of the material.
  26687. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26688. */
  26689. reflectionFresnelParameters: FresnelParameters;
  26690. private _refractionFresnelParameters;
  26691. /**
  26692. * Define the refraction fresnel parameters of the material.
  26693. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26694. */
  26695. refractionFresnelParameters: FresnelParameters;
  26696. private _emissiveFresnelParameters;
  26697. /**
  26698. * Define the emissive fresnel parameters of the material.
  26699. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26700. */
  26701. emissiveFresnelParameters: FresnelParameters;
  26702. private _useReflectionFresnelFromSpecular;
  26703. /**
  26704. * If true automatically deducts the fresnels values from the material specularity.
  26705. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26706. */
  26707. useReflectionFresnelFromSpecular: boolean;
  26708. private _useGlossinessFromSpecularMapAlpha;
  26709. /**
  26710. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26711. */
  26712. useGlossinessFromSpecularMapAlpha: boolean;
  26713. private _maxSimultaneousLights;
  26714. /**
  26715. * Defines the maximum number of lights that can be used in the material
  26716. */
  26717. maxSimultaneousLights: number;
  26718. private _invertNormalMapX;
  26719. /**
  26720. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26721. */
  26722. invertNormalMapX: boolean;
  26723. private _invertNormalMapY;
  26724. /**
  26725. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26726. */
  26727. invertNormalMapY: boolean;
  26728. private _twoSidedLighting;
  26729. /**
  26730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26731. */
  26732. twoSidedLighting: boolean;
  26733. /**
  26734. * Default configuration related to image processing available in the standard Material.
  26735. */
  26736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26737. /**
  26738. * Gets the image processing configuration used either in this material.
  26739. */
  26740. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26741. /**
  26742. * Sets the Default image processing configuration used either in the this material.
  26743. *
  26744. * If sets to null, the scene one is in use.
  26745. */
  26746. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26747. /**
  26748. * Keep track of the image processing observer to allow dispose and replace.
  26749. */
  26750. private _imageProcessingObserver;
  26751. /**
  26752. * Attaches a new image processing configuration to the Standard Material.
  26753. * @param configuration
  26754. */
  26755. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26756. /**
  26757. * Gets wether the color curves effect is enabled.
  26758. */
  26759. get cameraColorCurvesEnabled(): boolean;
  26760. /**
  26761. * Sets wether the color curves effect is enabled.
  26762. */
  26763. set cameraColorCurvesEnabled(value: boolean);
  26764. /**
  26765. * Gets wether the color grading effect is enabled.
  26766. */
  26767. get cameraColorGradingEnabled(): boolean;
  26768. /**
  26769. * Gets wether the color grading effect is enabled.
  26770. */
  26771. set cameraColorGradingEnabled(value: boolean);
  26772. /**
  26773. * Gets wether tonemapping is enabled or not.
  26774. */
  26775. get cameraToneMappingEnabled(): boolean;
  26776. /**
  26777. * Sets wether tonemapping is enabled or not
  26778. */
  26779. set cameraToneMappingEnabled(value: boolean);
  26780. /**
  26781. * The camera exposure used on this material.
  26782. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26783. * This corresponds to a photographic exposure.
  26784. */
  26785. get cameraExposure(): number;
  26786. /**
  26787. * The camera exposure used on this material.
  26788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26789. * This corresponds to a photographic exposure.
  26790. */
  26791. set cameraExposure(value: number);
  26792. /**
  26793. * Gets The camera contrast used on this material.
  26794. */
  26795. get cameraContrast(): number;
  26796. /**
  26797. * Sets The camera contrast used on this material.
  26798. */
  26799. set cameraContrast(value: number);
  26800. /**
  26801. * Gets the Color Grading 2D Lookup Texture.
  26802. */
  26803. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26804. /**
  26805. * Sets the Color Grading 2D Lookup Texture.
  26806. */
  26807. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26808. /**
  26809. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26810. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26811. * 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;
  26812. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26813. */
  26814. get cameraColorCurves(): Nullable<ColorCurves>;
  26815. /**
  26816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26818. * 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;
  26819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26820. */
  26821. set cameraColorCurves(value: Nullable<ColorCurves>);
  26822. /**
  26823. * Custom callback helping to override the default shader used in the material.
  26824. */
  26825. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26826. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26827. protected _worldViewProjectionMatrix: Matrix;
  26828. protected _globalAmbientColor: Color3;
  26829. protected _useLogarithmicDepth: boolean;
  26830. protected _rebuildInParallel: boolean;
  26831. /**
  26832. * Instantiates a new standard material.
  26833. * This is the default material used in Babylon. It is the best trade off between quality
  26834. * and performances.
  26835. * @see http://doc.babylonjs.com/babylon101/materials
  26836. * @param name Define the name of the material in the scene
  26837. * @param scene Define the scene the material belong to
  26838. */
  26839. constructor(name: string, scene: Scene);
  26840. /**
  26841. * Gets a boolean indicating that current material needs to register RTT
  26842. */
  26843. get hasRenderTargetTextures(): boolean;
  26844. /**
  26845. * Gets the current class name of the material e.g. "StandardMaterial"
  26846. * Mainly use in serialization.
  26847. * @returns the class name
  26848. */
  26849. getClassName(): string;
  26850. /**
  26851. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26852. * You can try switching to logarithmic depth.
  26853. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26854. */
  26855. get useLogarithmicDepth(): boolean;
  26856. set useLogarithmicDepth(value: boolean);
  26857. /**
  26858. * Specifies if the material will require alpha blending
  26859. * @returns a boolean specifying if alpha blending is needed
  26860. */
  26861. needAlphaBlending(): boolean;
  26862. /**
  26863. * Specifies if this material should be rendered in alpha test mode
  26864. * @returns a boolean specifying if an alpha test is needed.
  26865. */
  26866. needAlphaTesting(): boolean;
  26867. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26868. /**
  26869. * Get the texture used for alpha test purpose.
  26870. * @returns the diffuse texture in case of the standard material.
  26871. */
  26872. getAlphaTestTexture(): Nullable<BaseTexture>;
  26873. /**
  26874. * Get if the submesh is ready to be used and all its information available.
  26875. * Child classes can use it to update shaders
  26876. * @param mesh defines the mesh to check
  26877. * @param subMesh defines which submesh to check
  26878. * @param useInstances specifies that instances should be used
  26879. * @returns a boolean indicating that the submesh is ready or not
  26880. */
  26881. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26882. /**
  26883. * Builds the material UBO layouts.
  26884. * Used internally during the effect preparation.
  26885. */
  26886. buildUniformLayout(): void;
  26887. /**
  26888. * Unbinds the material from the mesh
  26889. */
  26890. unbind(): void;
  26891. /**
  26892. * Binds the submesh to this material by preparing the effect and shader to draw
  26893. * @param world defines the world transformation matrix
  26894. * @param mesh defines the mesh containing the submesh
  26895. * @param subMesh defines the submesh to bind the material to
  26896. */
  26897. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26898. /**
  26899. * Get the list of animatables in the material.
  26900. * @returns the list of animatables object used in the material
  26901. */
  26902. getAnimatables(): IAnimatable[];
  26903. /**
  26904. * Gets the active textures from the material
  26905. * @returns an array of textures
  26906. */
  26907. getActiveTextures(): BaseTexture[];
  26908. /**
  26909. * Specifies if the material uses a texture
  26910. * @param texture defines the texture to check against the material
  26911. * @returns a boolean specifying if the material uses the texture
  26912. */
  26913. hasTexture(texture: BaseTexture): boolean;
  26914. /**
  26915. * Disposes the material
  26916. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26917. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26918. */
  26919. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26920. /**
  26921. * Makes a duplicate of the material, and gives it a new name
  26922. * @param name defines the new name for the duplicated material
  26923. * @returns the cloned material
  26924. */
  26925. clone(name: string): StandardMaterial;
  26926. /**
  26927. * Serializes this material in a JSON representation
  26928. * @returns the serialized material object
  26929. */
  26930. serialize(): any;
  26931. /**
  26932. * Creates a standard material from parsed material data
  26933. * @param source defines the JSON representation of the material
  26934. * @param scene defines the hosting scene
  26935. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26936. * @returns a new standard material
  26937. */
  26938. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26939. /**
  26940. * Are diffuse textures enabled in the application.
  26941. */
  26942. static get DiffuseTextureEnabled(): boolean;
  26943. static set DiffuseTextureEnabled(value: boolean);
  26944. /**
  26945. * Are ambient textures enabled in the application.
  26946. */
  26947. static get AmbientTextureEnabled(): boolean;
  26948. static set AmbientTextureEnabled(value: boolean);
  26949. /**
  26950. * Are opacity textures enabled in the application.
  26951. */
  26952. static get OpacityTextureEnabled(): boolean;
  26953. static set OpacityTextureEnabled(value: boolean);
  26954. /**
  26955. * Are reflection textures enabled in the application.
  26956. */
  26957. static get ReflectionTextureEnabled(): boolean;
  26958. static set ReflectionTextureEnabled(value: boolean);
  26959. /**
  26960. * Are emissive textures enabled in the application.
  26961. */
  26962. static get EmissiveTextureEnabled(): boolean;
  26963. static set EmissiveTextureEnabled(value: boolean);
  26964. /**
  26965. * Are specular textures enabled in the application.
  26966. */
  26967. static get SpecularTextureEnabled(): boolean;
  26968. static set SpecularTextureEnabled(value: boolean);
  26969. /**
  26970. * Are bump textures enabled in the application.
  26971. */
  26972. static get BumpTextureEnabled(): boolean;
  26973. static set BumpTextureEnabled(value: boolean);
  26974. /**
  26975. * Are lightmap textures enabled in the application.
  26976. */
  26977. static get LightmapTextureEnabled(): boolean;
  26978. static set LightmapTextureEnabled(value: boolean);
  26979. /**
  26980. * Are refraction textures enabled in the application.
  26981. */
  26982. static get RefractionTextureEnabled(): boolean;
  26983. static set RefractionTextureEnabled(value: boolean);
  26984. /**
  26985. * Are color grading textures enabled in the application.
  26986. */
  26987. static get ColorGradingTextureEnabled(): boolean;
  26988. static set ColorGradingTextureEnabled(value: boolean);
  26989. /**
  26990. * Are fresnels enabled in the application.
  26991. */
  26992. static get FresnelEnabled(): boolean;
  26993. static set FresnelEnabled(value: boolean);
  26994. }
  26995. }
  26996. declare module BABYLON {
  26997. /**
  26998. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26999. *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.
  27000. * The SPS is also a particle system. It provides some methods to manage the particles.
  27001. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27002. *
  27003. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27004. */
  27005. export class SolidParticleSystem implements IDisposable {
  27006. /**
  27007. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27008. * Example : var p = SPS.particles[i];
  27009. */
  27010. particles: SolidParticle[];
  27011. /**
  27012. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27013. */
  27014. nbParticles: number;
  27015. /**
  27016. * If the particles must ever face the camera (default false). Useful for planar particles.
  27017. */
  27018. billboard: boolean;
  27019. /**
  27020. * Recompute normals when adding a shape
  27021. */
  27022. recomputeNormals: boolean;
  27023. /**
  27024. * This a counter ofr your own usage. It's not set by any SPS functions.
  27025. */
  27026. counter: number;
  27027. /**
  27028. * The SPS name. This name is also given to the underlying mesh.
  27029. */
  27030. name: string;
  27031. /**
  27032. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27033. */
  27034. mesh: Mesh;
  27035. /**
  27036. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27037. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27038. */
  27039. vars: any;
  27040. /**
  27041. * This array is populated when the SPS is set as 'pickable'.
  27042. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27043. * Each element of this array is an object `{idx: int, faceId: int}`.
  27044. * `idx` is the picked particle index in the `SPS.particles` array
  27045. * `faceId` is the picked face index counted within this particle.
  27046. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27047. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27048. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27049. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27050. */
  27051. pickedParticles: {
  27052. idx: number;
  27053. faceId: number;
  27054. }[];
  27055. /**
  27056. * This array is populated when the SPS is set as 'pickable'
  27057. * Each key of this array is a submesh index.
  27058. * Each element of this array is a second array defined like this :
  27059. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27060. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27061. * `idx` is the picked particle index in the `SPS.particles` array
  27062. * `faceId` is the picked face index counted within this particle.
  27063. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27064. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27065. */
  27066. pickedBySubMesh: {
  27067. idx: number;
  27068. faceId: number;
  27069. }[][];
  27070. /**
  27071. * This array is populated when `enableDepthSort` is set to true.
  27072. * Each element of this array is an instance of the class DepthSortedParticle.
  27073. */
  27074. depthSortedParticles: DepthSortedParticle[];
  27075. /**
  27076. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27077. * @hidden
  27078. */
  27079. _bSphereOnly: boolean;
  27080. /**
  27081. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27082. * @hidden
  27083. */
  27084. _bSphereRadiusFactor: number;
  27085. private _scene;
  27086. private _positions;
  27087. private _indices;
  27088. private _normals;
  27089. private _colors;
  27090. private _uvs;
  27091. private _indices32;
  27092. private _positions32;
  27093. private _normals32;
  27094. private _fixedNormal32;
  27095. private _colors32;
  27096. private _uvs32;
  27097. private _index;
  27098. private _updatable;
  27099. private _pickable;
  27100. private _isVisibilityBoxLocked;
  27101. private _alwaysVisible;
  27102. private _depthSort;
  27103. private _expandable;
  27104. private _shapeCounter;
  27105. private _copy;
  27106. private _color;
  27107. private _computeParticleColor;
  27108. private _computeParticleTexture;
  27109. private _computeParticleRotation;
  27110. private _computeParticleVertex;
  27111. private _computeBoundingBox;
  27112. private _depthSortParticles;
  27113. private _camera;
  27114. private _mustUnrotateFixedNormals;
  27115. private _particlesIntersect;
  27116. private _needs32Bits;
  27117. private _isNotBuilt;
  27118. private _lastParticleId;
  27119. private _idxOfId;
  27120. private _multimaterialEnabled;
  27121. private _useModelMaterial;
  27122. private _indicesByMaterial;
  27123. private _materialIndexes;
  27124. private _depthSortFunction;
  27125. private _materialSortFunction;
  27126. private _materials;
  27127. private _multimaterial;
  27128. private _materialIndexesById;
  27129. private _defaultMaterial;
  27130. private _autoUpdateSubMeshes;
  27131. /**
  27132. * Creates a SPS (Solid Particle System) object.
  27133. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27134. * @param scene (Scene) is the scene in which the SPS is added.
  27135. * @param options defines the options of the sps e.g.
  27136. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27137. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27138. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27139. * * 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.
  27140. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27141. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27142. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27143. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27144. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27145. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27146. */
  27147. constructor(name: string, scene: Scene, options?: {
  27148. updatable?: boolean;
  27149. isPickable?: boolean;
  27150. enableDepthSort?: boolean;
  27151. particleIntersection?: boolean;
  27152. boundingSphereOnly?: boolean;
  27153. bSphereRadiusFactor?: number;
  27154. expandable?: boolean;
  27155. useModelMaterial?: boolean;
  27156. enableMultiMaterial?: boolean;
  27157. });
  27158. /**
  27159. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27160. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27161. * @returns the created mesh
  27162. */
  27163. buildMesh(): Mesh;
  27164. /**
  27165. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27166. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27167. * Thus the particles generated from `digest()` have their property `position` set yet.
  27168. * @param mesh ( Mesh ) is the mesh to be digested
  27169. * @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
  27170. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27171. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27172. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27173. * @returns the current SPS
  27174. */
  27175. digest(mesh: Mesh, options?: {
  27176. facetNb?: number;
  27177. number?: number;
  27178. delta?: number;
  27179. storage?: [];
  27180. }): SolidParticleSystem;
  27181. /**
  27182. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27183. * @hidden
  27184. */
  27185. private _unrotateFixedNormals;
  27186. /**
  27187. * Resets the temporary working copy particle
  27188. * @hidden
  27189. */
  27190. private _resetCopy;
  27191. /**
  27192. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27193. * @param p the current index in the positions array to be updated
  27194. * @param ind the current index in the indices array
  27195. * @param shape a Vector3 array, the shape geometry
  27196. * @param positions the positions array to be updated
  27197. * @param meshInd the shape indices array
  27198. * @param indices the indices array to be updated
  27199. * @param meshUV the shape uv array
  27200. * @param uvs the uv array to be updated
  27201. * @param meshCol the shape color array
  27202. * @param colors the color array to be updated
  27203. * @param meshNor the shape normals array
  27204. * @param normals the normals array to be updated
  27205. * @param idx the particle index
  27206. * @param idxInShape the particle index in its shape
  27207. * @param options the addShape() method passed options
  27208. * @model the particle model
  27209. * @hidden
  27210. */
  27211. private _meshBuilder;
  27212. /**
  27213. * Returns a shape Vector3 array from positions float array
  27214. * @param positions float array
  27215. * @returns a vector3 array
  27216. * @hidden
  27217. */
  27218. private _posToShape;
  27219. /**
  27220. * Returns a shapeUV array from a float uvs (array deep copy)
  27221. * @param uvs as a float array
  27222. * @returns a shapeUV array
  27223. * @hidden
  27224. */
  27225. private _uvsToShapeUV;
  27226. /**
  27227. * Adds a new particle object in the particles array
  27228. * @param idx particle index in particles array
  27229. * @param id particle id
  27230. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27231. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27232. * @param model particle ModelShape object
  27233. * @param shapeId model shape identifier
  27234. * @param idxInShape index of the particle in the current model
  27235. * @param bInfo model bounding info object
  27236. * @param storage target storage array, if any
  27237. * @hidden
  27238. */
  27239. private _addParticle;
  27240. /**
  27241. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27242. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27243. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27244. * @param nb (positive integer) the number of particles to be created from this model
  27245. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27246. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27247. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27248. * @returns the number of shapes in the system
  27249. */
  27250. addShape(mesh: Mesh, nb: number, options?: {
  27251. positionFunction?: any;
  27252. vertexFunction?: any;
  27253. storage?: [];
  27254. }): number;
  27255. /**
  27256. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27257. * @hidden
  27258. */
  27259. private _rebuildParticle;
  27260. /**
  27261. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27262. * @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.
  27263. * @returns the SPS.
  27264. */
  27265. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27266. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27267. * Returns an array with the removed particles.
  27268. * 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.
  27269. * The SPS can't be empty so at least one particle needs to remain in place.
  27270. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27271. * @param start index of the first particle to remove
  27272. * @param end index of the last particle to remove (included)
  27273. * @returns an array populated with the removed particles
  27274. */
  27275. removeParticles(start: number, end: number): SolidParticle[];
  27276. /**
  27277. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27278. * @param solidParticleArray an array populated with Solid Particles objects
  27279. * @returns the SPS
  27280. */
  27281. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27282. /**
  27283. * Creates a new particle and modifies the SPS mesh geometry :
  27284. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27285. * - calls _addParticle() to populate the particle array
  27286. * factorized code from addShape() and insertParticlesFromArray()
  27287. * @param idx particle index in the particles array
  27288. * @param i particle index in its shape
  27289. * @param modelShape particle ModelShape object
  27290. * @param shape shape vertex array
  27291. * @param meshInd shape indices array
  27292. * @param meshUV shape uv array
  27293. * @param meshCol shape color array
  27294. * @param meshNor shape normals array
  27295. * @param bbInfo shape bounding info
  27296. * @param storage target particle storage
  27297. * @options addShape() passed options
  27298. * @hidden
  27299. */
  27300. private _insertNewParticle;
  27301. /**
  27302. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27303. * This method calls `updateParticle()` for each particle of the SPS.
  27304. * For an animated SPS, it is usually called within the render loop.
  27305. * 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.
  27306. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27307. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27308. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27309. * @returns the SPS.
  27310. */
  27311. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27312. /**
  27313. * Disposes the SPS.
  27314. */
  27315. dispose(): void;
  27316. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27317. * idx is the particle index in the SPS
  27318. * faceId is the picked face index counted within this particle.
  27319. * Returns null if the pickInfo can't identify a picked particle.
  27320. * @param pickingInfo (PickingInfo object)
  27321. * @returns {idx: number, faceId: number} or null
  27322. */
  27323. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27324. idx: number;
  27325. faceId: number;
  27326. }>;
  27327. /**
  27328. * Returns a SolidParticle object from its identifier : particle.id
  27329. * @param id (integer) the particle Id
  27330. * @returns the searched particle or null if not found in the SPS.
  27331. */
  27332. getParticleById(id: number): Nullable<SolidParticle>;
  27333. /**
  27334. * Returns a new array populated with the particles having the passed shapeId.
  27335. * @param shapeId (integer) the shape identifier
  27336. * @returns a new solid particle array
  27337. */
  27338. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27339. /**
  27340. * Populates the passed array "ref" with the particles having the passed shapeId.
  27341. * @param shapeId the shape identifier
  27342. * @returns the SPS
  27343. * @param ref
  27344. */
  27345. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27346. /**
  27347. * Computes the required SubMeshes according the materials assigned to the particles.
  27348. * @returns the solid particle system.
  27349. * Does nothing if called before the SPS mesh is built.
  27350. */
  27351. computeSubMeshes(): SolidParticleSystem;
  27352. /**
  27353. * Sorts the solid particles by material when MultiMaterial is enabled.
  27354. * Updates the indices32 array.
  27355. * Updates the indicesByMaterial array.
  27356. * Updates the mesh indices array.
  27357. * @returns the SPS
  27358. * @hidden
  27359. */
  27360. private _sortParticlesByMaterial;
  27361. /**
  27362. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27363. * @hidden
  27364. */
  27365. private _setMaterialIndexesById;
  27366. /**
  27367. * Returns an array with unique values of Materials from the passed array
  27368. * @param array the material array to be checked and filtered
  27369. * @hidden
  27370. */
  27371. private _filterUniqueMaterialId;
  27372. /**
  27373. * Sets a new Standard Material as _defaultMaterial if not already set.
  27374. * @hidden
  27375. */
  27376. private _setDefaultMaterial;
  27377. /**
  27378. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27380. * @returns the SPS.
  27381. */
  27382. refreshVisibleSize(): SolidParticleSystem;
  27383. /**
  27384. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27385. * @param size the size (float) of the visibility box
  27386. * note : this doesn't lock the SPS mesh bounding box.
  27387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27388. */
  27389. setVisibilityBox(size: number): void;
  27390. /**
  27391. * Gets whether the SPS as always visible or not
  27392. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27393. */
  27394. get isAlwaysVisible(): boolean;
  27395. /**
  27396. * Sets the SPS as always visible or not
  27397. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27398. */
  27399. set isAlwaysVisible(val: boolean);
  27400. /**
  27401. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27402. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27403. */
  27404. set isVisibilityBoxLocked(val: boolean);
  27405. /**
  27406. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27408. */
  27409. get isVisibilityBoxLocked(): boolean;
  27410. /**
  27411. * Tells to `setParticles()` to compute the particle rotations or not.
  27412. * Default value : true. The SPS is faster when it's set to false.
  27413. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27414. */
  27415. set computeParticleRotation(val: boolean);
  27416. /**
  27417. * Tells to `setParticles()` to compute the particle colors or not.
  27418. * Default value : true. The SPS is faster when it's set to false.
  27419. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27420. */
  27421. set computeParticleColor(val: boolean);
  27422. set computeParticleTexture(val: boolean);
  27423. /**
  27424. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27425. * Default value : false. The SPS is faster when it's set to false.
  27426. * Note : the particle custom vertex positions aren't stored values.
  27427. */
  27428. set computeParticleVertex(val: boolean);
  27429. /**
  27430. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27431. */
  27432. set computeBoundingBox(val: boolean);
  27433. /**
  27434. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27435. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27436. * Default : `true`
  27437. */
  27438. set depthSortParticles(val: boolean);
  27439. /**
  27440. * Gets if `setParticles()` computes the particle rotations or not.
  27441. * Default value : true. The SPS is faster when it's set to false.
  27442. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27443. */
  27444. get computeParticleRotation(): boolean;
  27445. /**
  27446. * Gets if `setParticles()` computes the particle colors or not.
  27447. * Default value : true. The SPS is faster when it's set to false.
  27448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27449. */
  27450. get computeParticleColor(): boolean;
  27451. /**
  27452. * Gets if `setParticles()` computes the particle textures or not.
  27453. * Default value : true. The SPS is faster when it's set to false.
  27454. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27455. */
  27456. get computeParticleTexture(): boolean;
  27457. /**
  27458. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27459. * Default value : false. The SPS is faster when it's set to false.
  27460. * Note : the particle custom vertex positions aren't stored values.
  27461. */
  27462. get computeParticleVertex(): boolean;
  27463. /**
  27464. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27465. */
  27466. get computeBoundingBox(): boolean;
  27467. /**
  27468. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27469. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27470. * Default : `true`
  27471. */
  27472. get depthSortParticles(): boolean;
  27473. /**
  27474. * Gets if the SPS is created as expandable at construction time.
  27475. * Default : `false`
  27476. */
  27477. get expandable(): boolean;
  27478. /**
  27479. * Gets if the SPS supports the Multi Materials
  27480. */
  27481. get multimaterialEnabled(): boolean;
  27482. /**
  27483. * Gets if the SPS uses the model materials for its own multimaterial.
  27484. */
  27485. get useModelMaterial(): boolean;
  27486. /**
  27487. * The SPS used material array.
  27488. */
  27489. get materials(): Material[];
  27490. /**
  27491. * Sets the SPS MultiMaterial from the passed materials.
  27492. * Note : the passed array is internally copied and not used then by reference.
  27493. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27494. */
  27495. setMultiMaterial(materials: Material[]): void;
  27496. /**
  27497. * The SPS computed multimaterial object
  27498. */
  27499. get multimaterial(): MultiMaterial;
  27500. set multimaterial(mm: MultiMaterial);
  27501. /**
  27502. * If the subMeshes must be updated on the next call to setParticles()
  27503. */
  27504. get autoUpdateSubMeshes(): boolean;
  27505. set autoUpdateSubMeshes(val: boolean);
  27506. /**
  27507. * This function does nothing. It may be overwritten to set all the particle first values.
  27508. * The SPS doesn't call this function, you may have to call it by your own.
  27509. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27510. */
  27511. initParticles(): void;
  27512. /**
  27513. * This function does nothing. It may be overwritten to recycle a particle.
  27514. * The SPS doesn't call this function, you may have to call it by your own.
  27515. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27516. * @param particle The particle to recycle
  27517. * @returns the recycled particle
  27518. */
  27519. recycleParticle(particle: SolidParticle): SolidParticle;
  27520. /**
  27521. * Updates a particle : this function should be overwritten by the user.
  27522. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27523. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27524. * @example : just set a particle position or velocity and recycle conditions
  27525. * @param particle The particle to update
  27526. * @returns the updated particle
  27527. */
  27528. updateParticle(particle: SolidParticle): SolidParticle;
  27529. /**
  27530. * Updates a vertex of a particle : it can be overwritten by the user.
  27531. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27532. * @param particle the current particle
  27533. * @param vertex the current index of the current particle
  27534. * @param pt the index of the current vertex in the particle shape
  27535. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27536. * @example : just set a vertex particle position
  27537. * @returns the updated vertex
  27538. */
  27539. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27540. /**
  27541. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27542. * This does nothing and may be overwritten by the user.
  27543. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27544. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27545. * @param update the boolean update value actually passed to setParticles()
  27546. */
  27547. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27548. /**
  27549. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27550. * This will be passed three parameters.
  27551. * This does nothing and may be overwritten by the user.
  27552. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27553. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27554. * @param update the boolean update value actually passed to setParticles()
  27555. */
  27556. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27557. }
  27558. }
  27559. declare module BABYLON {
  27560. /**
  27561. * Represents one particle of a solid particle system.
  27562. */
  27563. export class SolidParticle {
  27564. /**
  27565. * particle global index
  27566. */
  27567. idx: number;
  27568. /**
  27569. * particle identifier
  27570. */
  27571. id: number;
  27572. /**
  27573. * The color of the particle
  27574. */
  27575. color: Nullable<Color4>;
  27576. /**
  27577. * The world space position of the particle.
  27578. */
  27579. position: Vector3;
  27580. /**
  27581. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27582. */
  27583. rotation: Vector3;
  27584. /**
  27585. * The world space rotation quaternion of the particle.
  27586. */
  27587. rotationQuaternion: Nullable<Quaternion>;
  27588. /**
  27589. * The scaling of the particle.
  27590. */
  27591. scaling: Vector3;
  27592. /**
  27593. * The uvs of the particle.
  27594. */
  27595. uvs: Vector4;
  27596. /**
  27597. * The current speed of the particle.
  27598. */
  27599. velocity: Vector3;
  27600. /**
  27601. * The pivot point in the particle local space.
  27602. */
  27603. pivot: Vector3;
  27604. /**
  27605. * Must the particle be translated from its pivot point in its local space ?
  27606. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27607. * Default : false
  27608. */
  27609. translateFromPivot: boolean;
  27610. /**
  27611. * Is the particle active or not ?
  27612. */
  27613. alive: boolean;
  27614. /**
  27615. * Is the particle visible or not ?
  27616. */
  27617. isVisible: boolean;
  27618. /**
  27619. * Index of this particle in the global "positions" array (Internal use)
  27620. * @hidden
  27621. */
  27622. _pos: number;
  27623. /**
  27624. * @hidden Index of this particle in the global "indices" array (Internal use)
  27625. */
  27626. _ind: number;
  27627. /**
  27628. * @hidden ModelShape of this particle (Internal use)
  27629. */
  27630. _model: ModelShape;
  27631. /**
  27632. * ModelShape id of this particle
  27633. */
  27634. shapeId: number;
  27635. /**
  27636. * Index of the particle in its shape id
  27637. */
  27638. idxInShape: number;
  27639. /**
  27640. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27641. */
  27642. _modelBoundingInfo: BoundingInfo;
  27643. /**
  27644. * @hidden Particle BoundingInfo object (Internal use)
  27645. */
  27646. _boundingInfo: BoundingInfo;
  27647. /**
  27648. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27649. */
  27650. _sps: SolidParticleSystem;
  27651. /**
  27652. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27653. */
  27654. _stillInvisible: boolean;
  27655. /**
  27656. * @hidden Last computed particle rotation matrix
  27657. */
  27658. _rotationMatrix: number[];
  27659. /**
  27660. * Parent particle Id, if any.
  27661. * Default null.
  27662. */
  27663. parentId: Nullable<number>;
  27664. /**
  27665. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27666. */
  27667. materialIndex: Nullable<number>;
  27668. /**
  27669. * Custom object or properties.
  27670. */
  27671. props: Nullable<any>;
  27672. /**
  27673. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27674. * The possible values are :
  27675. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27676. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27677. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27678. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27679. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27680. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27681. * */
  27682. cullingStrategy: number;
  27683. /**
  27684. * @hidden Internal global position in the SPS.
  27685. */
  27686. _globalPosition: Vector3;
  27687. /**
  27688. * Creates a Solid Particle object.
  27689. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27690. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27691. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27692. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27693. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27694. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27695. * @param shapeId (integer) is the model shape identifier in the SPS.
  27696. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27697. * @param sps defines the sps it is associated to
  27698. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27699. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27700. */
  27701. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27702. /**
  27703. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27704. * @param target the particle target
  27705. * @returns the current particle
  27706. */
  27707. copyToRef(target: SolidParticle): SolidParticle;
  27708. /**
  27709. * Legacy support, changed scale to scaling
  27710. */
  27711. get scale(): Vector3;
  27712. /**
  27713. * Legacy support, changed scale to scaling
  27714. */
  27715. set scale(scale: Vector3);
  27716. /**
  27717. * Legacy support, changed quaternion to rotationQuaternion
  27718. */
  27719. get quaternion(): Nullable<Quaternion>;
  27720. /**
  27721. * Legacy support, changed quaternion to rotationQuaternion
  27722. */
  27723. set quaternion(q: Nullable<Quaternion>);
  27724. /**
  27725. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27726. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27727. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27728. * @returns true if it intersects
  27729. */
  27730. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27731. /**
  27732. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27733. * A particle is in the frustum if its bounding box intersects the frustum
  27734. * @param frustumPlanes defines the frustum to test
  27735. * @returns true if the particle is in the frustum planes
  27736. */
  27737. isInFrustum(frustumPlanes: Plane[]): boolean;
  27738. /**
  27739. * get the rotation matrix of the particle
  27740. * @hidden
  27741. */
  27742. getRotationMatrix(m: Matrix): void;
  27743. }
  27744. /**
  27745. * Represents the shape of the model used by one particle of a solid particle system.
  27746. * SPS internal tool, don't use it manually.
  27747. */
  27748. export class ModelShape {
  27749. /**
  27750. * The shape id
  27751. * @hidden
  27752. */
  27753. shapeID: number;
  27754. /**
  27755. * flat array of model positions (internal use)
  27756. * @hidden
  27757. */
  27758. _shape: Vector3[];
  27759. /**
  27760. * flat array of model UVs (internal use)
  27761. * @hidden
  27762. */
  27763. _shapeUV: number[];
  27764. /**
  27765. * color array of the model
  27766. * @hidden
  27767. */
  27768. _shapeColors: number[];
  27769. /**
  27770. * indices array of the model
  27771. * @hidden
  27772. */
  27773. _indices: number[];
  27774. /**
  27775. * normals array of the model
  27776. * @hidden
  27777. */
  27778. _normals: number[];
  27779. /**
  27780. * length of the shape in the model indices array (internal use)
  27781. * @hidden
  27782. */
  27783. _indicesLength: number;
  27784. /**
  27785. * Custom position function (internal use)
  27786. * @hidden
  27787. */
  27788. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27789. /**
  27790. * Custom vertex function (internal use)
  27791. * @hidden
  27792. */
  27793. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27794. /**
  27795. * Model material (internal use)
  27796. * @hidden
  27797. */
  27798. _material: Nullable<Material>;
  27799. /**
  27800. * 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.
  27801. * SPS internal tool, don't use it manually.
  27802. * @hidden
  27803. */
  27804. 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>);
  27805. }
  27806. /**
  27807. * Represents a Depth Sorted Particle in the solid particle system.
  27808. * @hidden
  27809. */
  27810. export class DepthSortedParticle {
  27811. /**
  27812. * Particle index
  27813. */
  27814. idx: number;
  27815. /**
  27816. * Index of the particle in the "indices" array
  27817. */
  27818. ind: number;
  27819. /**
  27820. * Length of the particle shape in the "indices" array
  27821. */
  27822. indicesLength: number;
  27823. /**
  27824. * Squared distance from the particle to the camera
  27825. */
  27826. sqDistance: number;
  27827. /**
  27828. * Material index when used with MultiMaterials
  27829. */
  27830. materialIndex: number;
  27831. /**
  27832. * Creates a new sorted particle
  27833. * @param materialIndex
  27834. */
  27835. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  27836. }
  27837. }
  27838. declare module BABYLON {
  27839. /**
  27840. * @hidden
  27841. */
  27842. export class _MeshCollisionData {
  27843. _checkCollisions: boolean;
  27844. _collisionMask: number;
  27845. _collisionGroup: number;
  27846. _collider: Nullable<Collider>;
  27847. _oldPositionForCollisions: Vector3;
  27848. _diffPositionForCollisions: Vector3;
  27849. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27850. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27851. }
  27852. }
  27853. declare module BABYLON {
  27854. /** @hidden */
  27855. class _FacetDataStorage {
  27856. facetPositions: Vector3[];
  27857. facetNormals: Vector3[];
  27858. facetPartitioning: number[][];
  27859. facetNb: number;
  27860. partitioningSubdivisions: number;
  27861. partitioningBBoxRatio: number;
  27862. facetDataEnabled: boolean;
  27863. facetParameters: any;
  27864. bbSize: Vector3;
  27865. subDiv: {
  27866. max: number;
  27867. X: number;
  27868. Y: number;
  27869. Z: number;
  27870. };
  27871. facetDepthSort: boolean;
  27872. facetDepthSortEnabled: boolean;
  27873. depthSortedIndices: IndicesArray;
  27874. depthSortedFacets: {
  27875. ind: number;
  27876. sqDistance: number;
  27877. }[];
  27878. facetDepthSortFunction: (f1: {
  27879. ind: number;
  27880. sqDistance: number;
  27881. }, f2: {
  27882. ind: number;
  27883. sqDistance: number;
  27884. }) => number;
  27885. facetDepthSortFrom: Vector3;
  27886. facetDepthSortOrigin: Vector3;
  27887. invertedMatrix: Matrix;
  27888. }
  27889. /**
  27890. * @hidden
  27891. **/
  27892. class _InternalAbstractMeshDataInfo {
  27893. _hasVertexAlpha: boolean;
  27894. _useVertexColors: boolean;
  27895. _numBoneInfluencers: number;
  27896. _applyFog: boolean;
  27897. _receiveShadows: boolean;
  27898. _facetData: _FacetDataStorage;
  27899. _visibility: number;
  27900. _skeleton: Nullable<Skeleton>;
  27901. _layerMask: number;
  27902. _computeBonesUsingShaders: boolean;
  27903. _isActive: boolean;
  27904. _onlyForInstances: boolean;
  27905. _isActiveIntermediate: boolean;
  27906. _onlyForInstancesIntermediate: boolean;
  27907. _actAsRegularMesh: boolean;
  27908. }
  27909. /**
  27910. * Class used to store all common mesh properties
  27911. */
  27912. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27913. /** No occlusion */
  27914. static OCCLUSION_TYPE_NONE: number;
  27915. /** Occlusion set to optimisitic */
  27916. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27917. /** Occlusion set to strict */
  27918. static OCCLUSION_TYPE_STRICT: number;
  27919. /** Use an accurante occlusion algorithm */
  27920. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27921. /** Use a conservative occlusion algorithm */
  27922. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27923. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27924. * Test order :
  27925. * Is the bounding sphere outside the frustum ?
  27926. * If not, are the bounding box vertices outside the frustum ?
  27927. * It not, then the cullable object is in the frustum.
  27928. */
  27929. static readonly CULLINGSTRATEGY_STANDARD: number;
  27930. /** Culling strategy : Bounding Sphere Only.
  27931. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27932. * It's also less accurate than the standard because some not visible objects can still be selected.
  27933. * Test : is the bounding sphere outside the frustum ?
  27934. * If not, then the cullable object is in the frustum.
  27935. */
  27936. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27937. /** Culling strategy : Optimistic Inclusion.
  27938. * This in an inclusion test first, then the standard exclusion test.
  27939. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27940. * 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.
  27941. * Anyway, it's as accurate as the standard strategy.
  27942. * Test :
  27943. * Is the cullable object bounding sphere center in the frustum ?
  27944. * If not, apply the default culling strategy.
  27945. */
  27946. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27947. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27948. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27949. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27950. * 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.
  27951. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27952. * Test :
  27953. * Is the cullable object bounding sphere center in the frustum ?
  27954. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27955. */
  27956. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27957. /**
  27958. * No billboard
  27959. */
  27960. static get BILLBOARDMODE_NONE(): number;
  27961. /** Billboard on X axis */
  27962. static get BILLBOARDMODE_X(): number;
  27963. /** Billboard on Y axis */
  27964. static get BILLBOARDMODE_Y(): number;
  27965. /** Billboard on Z axis */
  27966. static get BILLBOARDMODE_Z(): number;
  27967. /** Billboard on all axes */
  27968. static get BILLBOARDMODE_ALL(): number;
  27969. /** Billboard on using position instead of orientation */
  27970. static get BILLBOARDMODE_USE_POSITION(): number;
  27971. /** @hidden */
  27972. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27973. /**
  27974. * The culling strategy to use to check whether the mesh must be rendered or not.
  27975. * This value can be changed at any time and will be used on the next render mesh selection.
  27976. * The possible values are :
  27977. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27978. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27979. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27980. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27981. * Please read each static variable documentation to get details about the culling process.
  27982. * */
  27983. cullingStrategy: number;
  27984. /**
  27985. * Gets the number of facets in the mesh
  27986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27987. */
  27988. get facetNb(): number;
  27989. /**
  27990. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27992. */
  27993. get partitioningSubdivisions(): number;
  27994. set partitioningSubdivisions(nb: number);
  27995. /**
  27996. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27997. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27999. */
  28000. get partitioningBBoxRatio(): number;
  28001. set partitioningBBoxRatio(ratio: number);
  28002. /**
  28003. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28004. * Works only for updatable meshes.
  28005. * Doesn't work with multi-materials
  28006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28007. */
  28008. get mustDepthSortFacets(): boolean;
  28009. set mustDepthSortFacets(sort: boolean);
  28010. /**
  28011. * The location (Vector3) where the facet depth sort must be computed from.
  28012. * By default, the active camera position.
  28013. * Used only when facet depth sort is enabled
  28014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28015. */
  28016. get facetDepthSortFrom(): Vector3;
  28017. set facetDepthSortFrom(location: Vector3);
  28018. /**
  28019. * gets a boolean indicating if facetData is enabled
  28020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28021. */
  28022. get isFacetDataEnabled(): boolean;
  28023. /** @hidden */
  28024. _updateNonUniformScalingState(value: boolean): boolean;
  28025. /**
  28026. * An event triggered when this mesh collides with another one
  28027. */
  28028. onCollideObservable: Observable<AbstractMesh>;
  28029. /** Set a function to call when this mesh collides with another one */
  28030. set onCollide(callback: () => void);
  28031. /**
  28032. * An event triggered when the collision's position changes
  28033. */
  28034. onCollisionPositionChangeObservable: Observable<Vector3>;
  28035. /** Set a function to call when the collision's position changes */
  28036. set onCollisionPositionChange(callback: () => void);
  28037. /**
  28038. * An event triggered when material is changed
  28039. */
  28040. onMaterialChangedObservable: Observable<AbstractMesh>;
  28041. /**
  28042. * Gets or sets the orientation for POV movement & rotation
  28043. */
  28044. definedFacingForward: boolean;
  28045. /** @hidden */
  28046. _occlusionQuery: Nullable<WebGLQuery>;
  28047. /** @hidden */
  28048. _renderingGroup: Nullable<RenderingGroup>;
  28049. /**
  28050. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28051. */
  28052. get visibility(): number;
  28053. /**
  28054. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28055. */
  28056. set visibility(value: number);
  28057. /** Gets or sets the alpha index used to sort transparent meshes
  28058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28059. */
  28060. alphaIndex: number;
  28061. /**
  28062. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28063. */
  28064. isVisible: boolean;
  28065. /**
  28066. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28067. */
  28068. isPickable: boolean;
  28069. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28070. showSubMeshesBoundingBox: boolean;
  28071. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28073. */
  28074. isBlocker: boolean;
  28075. /**
  28076. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28077. */
  28078. enablePointerMoveEvents: boolean;
  28079. /**
  28080. * Specifies the rendering group id for this mesh (0 by default)
  28081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28082. */
  28083. renderingGroupId: number;
  28084. private _material;
  28085. /** Gets or sets current material */
  28086. get material(): Nullable<Material>;
  28087. set material(value: Nullable<Material>);
  28088. /**
  28089. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28090. * @see http://doc.babylonjs.com/babylon101/shadows
  28091. */
  28092. get receiveShadows(): boolean;
  28093. set receiveShadows(value: boolean);
  28094. /** Defines color to use when rendering outline */
  28095. outlineColor: Color3;
  28096. /** Define width to use when rendering outline */
  28097. outlineWidth: number;
  28098. /** Defines color to use when rendering overlay */
  28099. overlayColor: Color3;
  28100. /** Defines alpha to use when rendering overlay */
  28101. overlayAlpha: number;
  28102. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28103. get hasVertexAlpha(): boolean;
  28104. set hasVertexAlpha(value: boolean);
  28105. /** 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) */
  28106. get useVertexColors(): boolean;
  28107. set useVertexColors(value: boolean);
  28108. /**
  28109. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28110. */
  28111. get computeBonesUsingShaders(): boolean;
  28112. set computeBonesUsingShaders(value: boolean);
  28113. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28114. get numBoneInfluencers(): number;
  28115. set numBoneInfluencers(value: number);
  28116. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28117. get applyFog(): boolean;
  28118. set applyFog(value: boolean);
  28119. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28120. useOctreeForRenderingSelection: boolean;
  28121. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28122. useOctreeForPicking: boolean;
  28123. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28124. useOctreeForCollisions: boolean;
  28125. /**
  28126. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28127. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28128. */
  28129. get layerMask(): number;
  28130. set layerMask(value: number);
  28131. /**
  28132. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28133. */
  28134. alwaysSelectAsActiveMesh: boolean;
  28135. /**
  28136. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28137. */
  28138. doNotSyncBoundingInfo: boolean;
  28139. /**
  28140. * Gets or sets the current action manager
  28141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28142. */
  28143. actionManager: Nullable<AbstractActionManager>;
  28144. private _meshCollisionData;
  28145. /**
  28146. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28148. */
  28149. ellipsoid: Vector3;
  28150. /**
  28151. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28153. */
  28154. ellipsoidOffset: Vector3;
  28155. /**
  28156. * Gets or sets a collision mask used to mask collisions (default is -1).
  28157. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28158. */
  28159. get collisionMask(): number;
  28160. set collisionMask(mask: number);
  28161. /**
  28162. * Gets or sets the current collision group mask (-1 by default).
  28163. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28164. */
  28165. get collisionGroup(): number;
  28166. set collisionGroup(mask: number);
  28167. /**
  28168. * Defines edge width used when edgesRenderer is enabled
  28169. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28170. */
  28171. edgesWidth: number;
  28172. /**
  28173. * Defines edge color used when edgesRenderer is enabled
  28174. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28175. */
  28176. edgesColor: Color4;
  28177. /** @hidden */
  28178. _edgesRenderer: Nullable<IEdgesRenderer>;
  28179. /** @hidden */
  28180. _masterMesh: Nullable<AbstractMesh>;
  28181. /** @hidden */
  28182. _boundingInfo: Nullable<BoundingInfo>;
  28183. /** @hidden */
  28184. _renderId: number;
  28185. /**
  28186. * Gets or sets the list of subMeshes
  28187. * @see http://doc.babylonjs.com/how_to/multi_materials
  28188. */
  28189. subMeshes: SubMesh[];
  28190. /** @hidden */
  28191. _intersectionsInProgress: AbstractMesh[];
  28192. /** @hidden */
  28193. _unIndexed: boolean;
  28194. /** @hidden */
  28195. _lightSources: Light[];
  28196. /** Gets the list of lights affecting that mesh */
  28197. get lightSources(): Light[];
  28198. /** @hidden */
  28199. get _positions(): Nullable<Vector3[]>;
  28200. /** @hidden */
  28201. _waitingData: {
  28202. lods: Nullable<any>;
  28203. actions: Nullable<any>;
  28204. freezeWorldMatrix: Nullable<boolean>;
  28205. };
  28206. /** @hidden */
  28207. _bonesTransformMatrices: Nullable<Float32Array>;
  28208. /** @hidden */
  28209. _transformMatrixTexture: Nullable<RawTexture>;
  28210. /**
  28211. * Gets or sets a skeleton to apply skining transformations
  28212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28213. */
  28214. set skeleton(value: Nullable<Skeleton>);
  28215. get skeleton(): Nullable<Skeleton>;
  28216. /**
  28217. * An event triggered when the mesh is rebuilt.
  28218. */
  28219. onRebuildObservable: Observable<AbstractMesh>;
  28220. /**
  28221. * Creates a new AbstractMesh
  28222. * @param name defines the name of the mesh
  28223. * @param scene defines the hosting scene
  28224. */
  28225. constructor(name: string, scene?: Nullable<Scene>);
  28226. /**
  28227. * Returns the string "AbstractMesh"
  28228. * @returns "AbstractMesh"
  28229. */
  28230. getClassName(): string;
  28231. /**
  28232. * Gets a string representation of the current mesh
  28233. * @param fullDetails defines a boolean indicating if full details must be included
  28234. * @returns a string representation of the current mesh
  28235. */
  28236. toString(fullDetails?: boolean): string;
  28237. /**
  28238. * @hidden
  28239. */
  28240. protected _getEffectiveParent(): Nullable<Node>;
  28241. /** @hidden */
  28242. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28243. /** @hidden */
  28244. _rebuild(): void;
  28245. /** @hidden */
  28246. _resyncLightSources(): void;
  28247. /** @hidden */
  28248. _resyncLightSource(light: Light): void;
  28249. /** @hidden */
  28250. _unBindEffect(): void;
  28251. /** @hidden */
  28252. _removeLightSource(light: Light, dispose: boolean): void;
  28253. private _markSubMeshesAsDirty;
  28254. /** @hidden */
  28255. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28256. /** @hidden */
  28257. _markSubMeshesAsAttributesDirty(): void;
  28258. /** @hidden */
  28259. _markSubMeshesAsMiscDirty(): void;
  28260. /**
  28261. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28262. */
  28263. get scaling(): Vector3;
  28264. set scaling(newScaling: Vector3);
  28265. /**
  28266. * Returns true if the mesh is blocked. Implemented by child classes
  28267. */
  28268. get isBlocked(): boolean;
  28269. /**
  28270. * Returns the mesh itself by default. Implemented by child classes
  28271. * @param camera defines the camera to use to pick the right LOD level
  28272. * @returns the currentAbstractMesh
  28273. */
  28274. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28275. /**
  28276. * Returns 0 by default. Implemented by child classes
  28277. * @returns an integer
  28278. */
  28279. getTotalVertices(): number;
  28280. /**
  28281. * Returns a positive integer : the total number of indices in this mesh geometry.
  28282. * @returns the numner of indices or zero if the mesh has no geometry.
  28283. */
  28284. getTotalIndices(): number;
  28285. /**
  28286. * Returns null by default. Implemented by child classes
  28287. * @returns null
  28288. */
  28289. getIndices(): Nullable<IndicesArray>;
  28290. /**
  28291. * Returns the array of the requested vertex data kind. Implemented by child classes
  28292. * @param kind defines the vertex data kind to use
  28293. * @returns null
  28294. */
  28295. getVerticesData(kind: string): Nullable<FloatArray>;
  28296. /**
  28297. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28298. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28299. * Note that a new underlying VertexBuffer object is created each call.
  28300. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28301. * @param kind defines vertex data kind:
  28302. * * VertexBuffer.PositionKind
  28303. * * VertexBuffer.UVKind
  28304. * * VertexBuffer.UV2Kind
  28305. * * VertexBuffer.UV3Kind
  28306. * * VertexBuffer.UV4Kind
  28307. * * VertexBuffer.UV5Kind
  28308. * * VertexBuffer.UV6Kind
  28309. * * VertexBuffer.ColorKind
  28310. * * VertexBuffer.MatricesIndicesKind
  28311. * * VertexBuffer.MatricesIndicesExtraKind
  28312. * * VertexBuffer.MatricesWeightsKind
  28313. * * VertexBuffer.MatricesWeightsExtraKind
  28314. * @param data defines the data source
  28315. * @param updatable defines if the data must be flagged as updatable (or static)
  28316. * @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
  28317. * @returns the current mesh
  28318. */
  28319. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28320. /**
  28321. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28322. * If the mesh has no geometry, it is simply returned as it is.
  28323. * @param kind defines vertex data kind:
  28324. * * VertexBuffer.PositionKind
  28325. * * VertexBuffer.UVKind
  28326. * * VertexBuffer.UV2Kind
  28327. * * VertexBuffer.UV3Kind
  28328. * * VertexBuffer.UV4Kind
  28329. * * VertexBuffer.UV5Kind
  28330. * * VertexBuffer.UV6Kind
  28331. * * VertexBuffer.ColorKind
  28332. * * VertexBuffer.MatricesIndicesKind
  28333. * * VertexBuffer.MatricesIndicesExtraKind
  28334. * * VertexBuffer.MatricesWeightsKind
  28335. * * VertexBuffer.MatricesWeightsExtraKind
  28336. * @param data defines the data source
  28337. * @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
  28338. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28339. * @returns the current mesh
  28340. */
  28341. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28342. /**
  28343. * Sets the mesh indices,
  28344. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28345. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28346. * @param totalVertices Defines the total number of vertices
  28347. * @returns the current mesh
  28348. */
  28349. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28350. /**
  28351. * Gets a boolean indicating if specific vertex data is present
  28352. * @param kind defines the vertex data kind to use
  28353. * @returns true is data kind is present
  28354. */
  28355. isVerticesDataPresent(kind: string): boolean;
  28356. /**
  28357. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28358. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28359. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28360. * @returns a BoundingInfo
  28361. */
  28362. getBoundingInfo(): BoundingInfo;
  28363. /**
  28364. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28365. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28366. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28367. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28368. * @returns the current mesh
  28369. */
  28370. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28371. /**
  28372. * Overwrite the current bounding info
  28373. * @param boundingInfo defines the new bounding info
  28374. * @returns the current mesh
  28375. */
  28376. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28377. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28378. get useBones(): boolean;
  28379. /** @hidden */
  28380. _preActivate(): void;
  28381. /** @hidden */
  28382. _preActivateForIntermediateRendering(renderId: number): void;
  28383. /** @hidden */
  28384. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28385. /** @hidden */
  28386. _postActivate(): void;
  28387. /** @hidden */
  28388. _freeze(): void;
  28389. /** @hidden */
  28390. _unFreeze(): void;
  28391. /**
  28392. * Gets the current world matrix
  28393. * @returns a Matrix
  28394. */
  28395. getWorldMatrix(): Matrix;
  28396. /** @hidden */
  28397. _getWorldMatrixDeterminant(): number;
  28398. /**
  28399. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28400. */
  28401. get isAnInstance(): boolean;
  28402. /**
  28403. * Gets a boolean indicating if this mesh has instances
  28404. */
  28405. get hasInstances(): boolean;
  28406. /**
  28407. * Perform relative position change from the point of view of behind the front of the mesh.
  28408. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28409. * Supports definition of mesh facing forward or backward
  28410. * @param amountRight defines the distance on the right axis
  28411. * @param amountUp defines the distance on the up axis
  28412. * @param amountForward defines the distance on the forward axis
  28413. * @returns the current mesh
  28414. */
  28415. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28416. /**
  28417. * Calculate relative position change from the point of view of behind the front of the mesh.
  28418. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28419. * Supports definition of mesh facing forward or backward
  28420. * @param amountRight defines the distance on the right axis
  28421. * @param amountUp defines the distance on the up axis
  28422. * @param amountForward defines the distance on the forward axis
  28423. * @returns the new displacement vector
  28424. */
  28425. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28426. /**
  28427. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28428. * Supports definition of mesh facing forward or backward
  28429. * @param flipBack defines the flip
  28430. * @param twirlClockwise defines the twirl
  28431. * @param tiltRight defines the tilt
  28432. * @returns the current mesh
  28433. */
  28434. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28435. /**
  28436. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28437. * Supports definition of mesh facing forward or backward.
  28438. * @param flipBack defines the flip
  28439. * @param twirlClockwise defines the twirl
  28440. * @param tiltRight defines the tilt
  28441. * @returns the new rotation vector
  28442. */
  28443. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28444. /**
  28445. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28446. * This means the mesh underlying bounding box and sphere are recomputed.
  28447. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28448. * @returns the current mesh
  28449. */
  28450. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28451. /** @hidden */
  28452. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28453. /** @hidden */
  28454. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28455. /** @hidden */
  28456. _updateBoundingInfo(): AbstractMesh;
  28457. /** @hidden */
  28458. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28459. /** @hidden */
  28460. protected _afterComputeWorldMatrix(): void;
  28461. /** @hidden */
  28462. get _effectiveMesh(): AbstractMesh;
  28463. /**
  28464. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28465. * A mesh is in the frustum if its bounding box intersects the frustum
  28466. * @param frustumPlanes defines the frustum to test
  28467. * @returns true if the mesh is in the frustum planes
  28468. */
  28469. isInFrustum(frustumPlanes: Plane[]): boolean;
  28470. /**
  28471. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28472. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28473. * @param frustumPlanes defines the frustum to test
  28474. * @returns true if the mesh is completely in the frustum planes
  28475. */
  28476. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28477. /**
  28478. * True if the mesh intersects another mesh or a SolidParticle object
  28479. * @param mesh defines a target mesh or SolidParticle to test
  28480. * @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)
  28481. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28482. * @returns true if there is an intersection
  28483. */
  28484. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28485. /**
  28486. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28487. * @param point defines the point to test
  28488. * @returns true if there is an intersection
  28489. */
  28490. intersectsPoint(point: Vector3): boolean;
  28491. /**
  28492. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28493. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28494. */
  28495. get checkCollisions(): boolean;
  28496. set checkCollisions(collisionEnabled: boolean);
  28497. /**
  28498. * Gets Collider object used to compute collisions (not physics)
  28499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28500. */
  28501. get collider(): Nullable<Collider>;
  28502. /**
  28503. * Move the mesh using collision engine
  28504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28505. * @param displacement defines the requested displacement vector
  28506. * @returns the current mesh
  28507. */
  28508. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28509. private _onCollisionPositionChange;
  28510. /** @hidden */
  28511. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28512. /** @hidden */
  28513. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28514. /** @hidden */
  28515. _checkCollision(collider: Collider): AbstractMesh;
  28516. /** @hidden */
  28517. _generatePointsArray(): boolean;
  28518. /**
  28519. * Checks if the passed Ray intersects with the mesh
  28520. * @param ray defines the ray to use
  28521. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28522. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28523. * @returns the picking info
  28524. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28525. */
  28526. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28527. /**
  28528. * Clones the current mesh
  28529. * @param name defines the mesh name
  28530. * @param newParent defines the new mesh parent
  28531. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28532. * @returns the new mesh
  28533. */
  28534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28535. /**
  28536. * Disposes all the submeshes of the current meshnp
  28537. * @returns the current mesh
  28538. */
  28539. releaseSubMeshes(): AbstractMesh;
  28540. /**
  28541. * Releases resources associated with this abstract mesh.
  28542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28544. */
  28545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28546. /**
  28547. * Adds the passed mesh as a child to the current mesh
  28548. * @param mesh defines the child mesh
  28549. * @returns the current mesh
  28550. */
  28551. addChild(mesh: AbstractMesh): AbstractMesh;
  28552. /**
  28553. * Removes the passed mesh from the current mesh children list
  28554. * @param mesh defines the child mesh
  28555. * @returns the current mesh
  28556. */
  28557. removeChild(mesh: AbstractMesh): AbstractMesh;
  28558. /** @hidden */
  28559. private _initFacetData;
  28560. /**
  28561. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28562. * This method can be called within the render loop.
  28563. * 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
  28564. * @returns the current mesh
  28565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28566. */
  28567. updateFacetData(): AbstractMesh;
  28568. /**
  28569. * Returns the facetLocalNormals array.
  28570. * The normals are expressed in the mesh local spac
  28571. * @returns an array of Vector3
  28572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28573. */
  28574. getFacetLocalNormals(): Vector3[];
  28575. /**
  28576. * Returns the facetLocalPositions array.
  28577. * The facet positions are expressed in the mesh local space
  28578. * @returns an array of Vector3
  28579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28580. */
  28581. getFacetLocalPositions(): Vector3[];
  28582. /**
  28583. * Returns the facetLocalPartioning array
  28584. * @returns an array of array of numbers
  28585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28586. */
  28587. getFacetLocalPartitioning(): number[][];
  28588. /**
  28589. * Returns the i-th facet position in the world system.
  28590. * This method allocates a new Vector3 per call
  28591. * @param i defines the facet index
  28592. * @returns a new Vector3
  28593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28594. */
  28595. getFacetPosition(i: number): Vector3;
  28596. /**
  28597. * Sets the reference Vector3 with the i-th facet position in the world system
  28598. * @param i defines the facet index
  28599. * @param ref defines the target vector
  28600. * @returns the current mesh
  28601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28602. */
  28603. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28604. /**
  28605. * Returns the i-th facet normal in the world system.
  28606. * This method allocates a new Vector3 per call
  28607. * @param i defines the facet index
  28608. * @returns a new Vector3
  28609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28610. */
  28611. getFacetNormal(i: number): Vector3;
  28612. /**
  28613. * Sets the reference Vector3 with the i-th facet normal in the world system
  28614. * @param i defines the facet index
  28615. * @param ref defines the target vector
  28616. * @returns the current mesh
  28617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28618. */
  28619. getFacetNormalToRef(i: number, ref: Vector3): this;
  28620. /**
  28621. * 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)
  28622. * @param x defines x coordinate
  28623. * @param y defines y coordinate
  28624. * @param z defines z coordinate
  28625. * @returns the array of facet indexes
  28626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28627. */
  28628. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28629. /**
  28630. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28631. * @param projected sets as the (x,y,z) world projection on the facet
  28632. * @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
  28633. * @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
  28634. * @param x defines x coordinate
  28635. * @param y defines y coordinate
  28636. * @param z defines z coordinate
  28637. * @returns the face index if found (or null instead)
  28638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28639. */
  28640. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28641. /**
  28642. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28643. * @param projected sets as the (x,y,z) local projection on the facet
  28644. * @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
  28645. * @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
  28646. * @param x defines x coordinate
  28647. * @param y defines y coordinate
  28648. * @param z defines z coordinate
  28649. * @returns the face index if found (or null instead)
  28650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28651. */
  28652. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28653. /**
  28654. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28655. * @returns the parameters
  28656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28657. */
  28658. getFacetDataParameters(): any;
  28659. /**
  28660. * Disables the feature FacetData and frees the related memory
  28661. * @returns the current mesh
  28662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28663. */
  28664. disableFacetData(): AbstractMesh;
  28665. /**
  28666. * Updates the AbstractMesh indices array
  28667. * @param indices defines the data source
  28668. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28669. * @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)
  28670. * @returns the current mesh
  28671. */
  28672. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28673. /**
  28674. * Creates new normals data for the mesh
  28675. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28676. * @returns the current mesh
  28677. */
  28678. createNormals(updatable: boolean): AbstractMesh;
  28679. /**
  28680. * Align the mesh with a normal
  28681. * @param normal defines the normal to use
  28682. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28683. * @returns the current mesh
  28684. */
  28685. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28686. /** @hidden */
  28687. _checkOcclusionQuery(): boolean;
  28688. /**
  28689. * Disables the mesh edge rendering mode
  28690. * @returns the currentAbstractMesh
  28691. */
  28692. disableEdgesRendering(): AbstractMesh;
  28693. /**
  28694. * Enables the edge rendering mode on the mesh.
  28695. * This mode makes the mesh edges visible
  28696. * @param epsilon defines the maximal distance between two angles to detect a face
  28697. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28698. * @returns the currentAbstractMesh
  28699. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28700. */
  28701. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28702. }
  28703. }
  28704. declare module BABYLON {
  28705. /**
  28706. * Interface used to define ActionEvent
  28707. */
  28708. export interface IActionEvent {
  28709. /** The mesh or sprite that triggered the action */
  28710. source: any;
  28711. /** The X mouse cursor position at the time of the event */
  28712. pointerX: number;
  28713. /** The Y mouse cursor position at the time of the event */
  28714. pointerY: number;
  28715. /** The mesh that is currently pointed at (can be null) */
  28716. meshUnderPointer: Nullable<AbstractMesh>;
  28717. /** the original (browser) event that triggered the ActionEvent */
  28718. sourceEvent?: any;
  28719. /** additional data for the event */
  28720. additionalData?: any;
  28721. }
  28722. /**
  28723. * ActionEvent is the event being sent when an action is triggered.
  28724. */
  28725. export class ActionEvent implements IActionEvent {
  28726. /** The mesh or sprite that triggered the action */
  28727. source: any;
  28728. /** The X mouse cursor position at the time of the event */
  28729. pointerX: number;
  28730. /** The Y mouse cursor position at the time of the event */
  28731. pointerY: number;
  28732. /** The mesh that is currently pointed at (can be null) */
  28733. meshUnderPointer: Nullable<AbstractMesh>;
  28734. /** the original (browser) event that triggered the ActionEvent */
  28735. sourceEvent?: any;
  28736. /** additional data for the event */
  28737. additionalData?: any;
  28738. /**
  28739. * Creates a new ActionEvent
  28740. * @param source The mesh or sprite that triggered the action
  28741. * @param pointerX The X mouse cursor position at the time of the event
  28742. * @param pointerY The Y mouse cursor position at the time of the event
  28743. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28744. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28745. * @param additionalData additional data for the event
  28746. */
  28747. constructor(
  28748. /** The mesh or sprite that triggered the action */
  28749. source: any,
  28750. /** The X mouse cursor position at the time of the event */
  28751. pointerX: number,
  28752. /** The Y mouse cursor position at the time of the event */
  28753. pointerY: number,
  28754. /** The mesh that is currently pointed at (can be null) */
  28755. meshUnderPointer: Nullable<AbstractMesh>,
  28756. /** the original (browser) event that triggered the ActionEvent */
  28757. sourceEvent?: any,
  28758. /** additional data for the event */
  28759. additionalData?: any);
  28760. /**
  28761. * Helper function to auto-create an ActionEvent from a source mesh.
  28762. * @param source The source mesh that triggered the event
  28763. * @param evt The original (browser) event
  28764. * @param additionalData additional data for the event
  28765. * @returns the new ActionEvent
  28766. */
  28767. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28768. /**
  28769. * Helper function to auto-create an ActionEvent from a source sprite
  28770. * @param source The source sprite that triggered the event
  28771. * @param scene Scene associated with the sprite
  28772. * @param evt The original (browser) event
  28773. * @param additionalData additional data for the event
  28774. * @returns the new ActionEvent
  28775. */
  28776. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28777. /**
  28778. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28779. * @param scene the scene where the event occurred
  28780. * @param evt The original (browser) event
  28781. * @returns the new ActionEvent
  28782. */
  28783. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28784. /**
  28785. * Helper function to auto-create an ActionEvent from a primitive
  28786. * @param prim defines the target primitive
  28787. * @param pointerPos defines the pointer position
  28788. * @param evt The original (browser) event
  28789. * @param additionalData additional data for the event
  28790. * @returns the new ActionEvent
  28791. */
  28792. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28793. }
  28794. }
  28795. declare module BABYLON {
  28796. /**
  28797. * Abstract class used to decouple action Manager from scene and meshes.
  28798. * Do not instantiate.
  28799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28800. */
  28801. export abstract class AbstractActionManager implements IDisposable {
  28802. /** Gets the list of active triggers */
  28803. static Triggers: {
  28804. [key: string]: number;
  28805. };
  28806. /** Gets the cursor to use when hovering items */
  28807. hoverCursor: string;
  28808. /** Gets the list of actions */
  28809. actions: IAction[];
  28810. /**
  28811. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28812. */
  28813. isRecursive: boolean;
  28814. /**
  28815. * Releases all associated resources
  28816. */
  28817. abstract dispose(): void;
  28818. /**
  28819. * Does this action manager has pointer triggers
  28820. */
  28821. abstract get hasPointerTriggers(): boolean;
  28822. /**
  28823. * Does this action manager has pick triggers
  28824. */
  28825. abstract get hasPickTriggers(): boolean;
  28826. /**
  28827. * Process a specific trigger
  28828. * @param trigger defines the trigger to process
  28829. * @param evt defines the event details to be processed
  28830. */
  28831. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28832. /**
  28833. * Does this action manager handles actions of any of the given triggers
  28834. * @param triggers defines the triggers to be tested
  28835. * @return a boolean indicating whether one (or more) of the triggers is handled
  28836. */
  28837. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28838. /**
  28839. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28840. * speed.
  28841. * @param triggerA defines the trigger to be tested
  28842. * @param triggerB defines the trigger to be tested
  28843. * @return a boolean indicating whether one (or more) of the triggers is handled
  28844. */
  28845. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28846. /**
  28847. * Does this action manager handles actions of a given trigger
  28848. * @param trigger defines the trigger to be tested
  28849. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28850. * @return whether the trigger is handled
  28851. */
  28852. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28853. /**
  28854. * Serialize this manager to a JSON object
  28855. * @param name defines the property name to store this manager
  28856. * @returns a JSON representation of this manager
  28857. */
  28858. abstract serialize(name: string): any;
  28859. /**
  28860. * Registers an action to this action manager
  28861. * @param action defines the action to be registered
  28862. * @return the action amended (prepared) after registration
  28863. */
  28864. abstract registerAction(action: IAction): Nullable<IAction>;
  28865. /**
  28866. * Unregisters an action to this action manager
  28867. * @param action defines the action to be unregistered
  28868. * @return a boolean indicating whether the action has been unregistered
  28869. */
  28870. abstract unregisterAction(action: IAction): Boolean;
  28871. /**
  28872. * Does exist one action manager with at least one trigger
  28873. **/
  28874. static get HasTriggers(): boolean;
  28875. /**
  28876. * Does exist one action manager with at least one pick trigger
  28877. **/
  28878. static get HasPickTriggers(): boolean;
  28879. /**
  28880. * Does exist one action manager that handles actions of a given trigger
  28881. * @param trigger defines the trigger to be tested
  28882. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28883. **/
  28884. static HasSpecificTrigger(trigger: number): boolean;
  28885. }
  28886. }
  28887. declare module BABYLON {
  28888. /**
  28889. * Defines how a node can be built from a string name.
  28890. */
  28891. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28892. /**
  28893. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28894. */
  28895. export class Node implements IBehaviorAware<Node> {
  28896. /** @hidden */
  28897. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28898. private static _NodeConstructors;
  28899. /**
  28900. * Add a new node constructor
  28901. * @param type defines the type name of the node to construct
  28902. * @param constructorFunc defines the constructor function
  28903. */
  28904. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28905. /**
  28906. * Returns a node constructor based on type name
  28907. * @param type defines the type name
  28908. * @param name defines the new node name
  28909. * @param scene defines the hosting scene
  28910. * @param options defines optional options to transmit to constructors
  28911. * @returns the new constructor or null
  28912. */
  28913. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28914. /**
  28915. * Gets or sets the name of the node
  28916. */
  28917. name: string;
  28918. /**
  28919. * Gets or sets the id of the node
  28920. */
  28921. id: string;
  28922. /**
  28923. * Gets or sets the unique id of the node
  28924. */
  28925. uniqueId: number;
  28926. /**
  28927. * Gets or sets a string used to store user defined state for the node
  28928. */
  28929. state: string;
  28930. /**
  28931. * Gets or sets an object used to store user defined information for the node
  28932. */
  28933. metadata: any;
  28934. /**
  28935. * For internal use only. Please do not use.
  28936. */
  28937. reservedDataStore: any;
  28938. /**
  28939. * List of inspectable custom properties (used by the Inspector)
  28940. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28941. */
  28942. inspectableCustomProperties: IInspectable[];
  28943. private _doNotSerialize;
  28944. /**
  28945. * Gets or sets a boolean used to define if the node must be serialized
  28946. */
  28947. get doNotSerialize(): boolean;
  28948. set doNotSerialize(value: boolean);
  28949. /** @hidden */
  28950. _isDisposed: boolean;
  28951. /**
  28952. * Gets a list of Animations associated with the node
  28953. */
  28954. animations: Animation[];
  28955. protected _ranges: {
  28956. [name: string]: Nullable<AnimationRange>;
  28957. };
  28958. /**
  28959. * Callback raised when the node is ready to be used
  28960. */
  28961. onReady: Nullable<(node: Node) => void>;
  28962. private _isEnabled;
  28963. private _isParentEnabled;
  28964. private _isReady;
  28965. /** @hidden */
  28966. _currentRenderId: number;
  28967. private _parentUpdateId;
  28968. /** @hidden */
  28969. _childUpdateId: number;
  28970. /** @hidden */
  28971. _waitingParentId: Nullable<string>;
  28972. /** @hidden */
  28973. _scene: Scene;
  28974. /** @hidden */
  28975. _cache: any;
  28976. private _parentNode;
  28977. private _children;
  28978. /** @hidden */
  28979. _worldMatrix: Matrix;
  28980. /** @hidden */
  28981. _worldMatrixDeterminant: number;
  28982. /** @hidden */
  28983. _worldMatrixDeterminantIsDirty: boolean;
  28984. /** @hidden */
  28985. private _sceneRootNodesIndex;
  28986. /**
  28987. * Gets a boolean indicating if the node has been disposed
  28988. * @returns true if the node was disposed
  28989. */
  28990. isDisposed(): boolean;
  28991. /**
  28992. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28993. * @see https://doc.babylonjs.com/how_to/parenting
  28994. */
  28995. set parent(parent: Nullable<Node>);
  28996. get parent(): Nullable<Node>;
  28997. /** @hidden */
  28998. _addToSceneRootNodes(): void;
  28999. /** @hidden */
  29000. _removeFromSceneRootNodes(): void;
  29001. private _animationPropertiesOverride;
  29002. /**
  29003. * Gets or sets the animation properties override
  29004. */
  29005. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29006. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29007. /**
  29008. * Gets a string idenfifying the name of the class
  29009. * @returns "Node" string
  29010. */
  29011. getClassName(): string;
  29012. /** @hidden */
  29013. readonly _isNode: boolean;
  29014. /**
  29015. * An event triggered when the mesh is disposed
  29016. */
  29017. onDisposeObservable: Observable<Node>;
  29018. private _onDisposeObserver;
  29019. /**
  29020. * Sets a callback that will be raised when the node will be disposed
  29021. */
  29022. set onDispose(callback: () => void);
  29023. /**
  29024. * Creates a new Node
  29025. * @param name the name and id to be given to this node
  29026. * @param scene the scene this node will be added to
  29027. */
  29028. constructor(name: string, scene?: Nullable<Scene>);
  29029. /**
  29030. * Gets the scene of the node
  29031. * @returns a scene
  29032. */
  29033. getScene(): Scene;
  29034. /**
  29035. * Gets the engine of the node
  29036. * @returns a Engine
  29037. */
  29038. getEngine(): Engine;
  29039. private _behaviors;
  29040. /**
  29041. * Attach a behavior to the node
  29042. * @see http://doc.babylonjs.com/features/behaviour
  29043. * @param behavior defines the behavior to attach
  29044. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29045. * @returns the current Node
  29046. */
  29047. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29048. /**
  29049. * Remove an attached behavior
  29050. * @see http://doc.babylonjs.com/features/behaviour
  29051. * @param behavior defines the behavior to attach
  29052. * @returns the current Node
  29053. */
  29054. removeBehavior(behavior: Behavior<Node>): Node;
  29055. /**
  29056. * Gets the list of attached behaviors
  29057. * @see http://doc.babylonjs.com/features/behaviour
  29058. */
  29059. get behaviors(): Behavior<Node>[];
  29060. /**
  29061. * Gets an attached behavior by name
  29062. * @param name defines the name of the behavior to look for
  29063. * @see http://doc.babylonjs.com/features/behaviour
  29064. * @returns null if behavior was not found else the requested behavior
  29065. */
  29066. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29067. /**
  29068. * Returns the latest update of the World matrix
  29069. * @returns a Matrix
  29070. */
  29071. getWorldMatrix(): Matrix;
  29072. /** @hidden */
  29073. _getWorldMatrixDeterminant(): number;
  29074. /**
  29075. * Returns directly the latest state of the mesh World matrix.
  29076. * A Matrix is returned.
  29077. */
  29078. get worldMatrixFromCache(): Matrix;
  29079. /** @hidden */
  29080. _initCache(): void;
  29081. /** @hidden */
  29082. updateCache(force?: boolean): void;
  29083. /** @hidden */
  29084. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29085. /** @hidden */
  29086. _updateCache(ignoreParentClass?: boolean): void;
  29087. /** @hidden */
  29088. _isSynchronized(): boolean;
  29089. /** @hidden */
  29090. _markSyncedWithParent(): void;
  29091. /** @hidden */
  29092. isSynchronizedWithParent(): boolean;
  29093. /** @hidden */
  29094. isSynchronized(): boolean;
  29095. /**
  29096. * Is this node ready to be used/rendered
  29097. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29098. * @return true if the node is ready
  29099. */
  29100. isReady(completeCheck?: boolean): boolean;
  29101. /**
  29102. * Is this node enabled?
  29103. * 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
  29104. * @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
  29105. * @return whether this node (and its parent) is enabled
  29106. */
  29107. isEnabled(checkAncestors?: boolean): boolean;
  29108. /** @hidden */
  29109. protected _syncParentEnabledState(): void;
  29110. /**
  29111. * Set the enabled state of this node
  29112. * @param value defines the new enabled state
  29113. */
  29114. setEnabled(value: boolean): void;
  29115. /**
  29116. * Is this node a descendant of the given node?
  29117. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29118. * @param ancestor defines the parent node to inspect
  29119. * @returns a boolean indicating if this node is a descendant of the given node
  29120. */
  29121. isDescendantOf(ancestor: Node): boolean;
  29122. /** @hidden */
  29123. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29124. /**
  29125. * Will return all nodes that have this node as ascendant
  29126. * @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
  29127. * @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
  29128. * @return all children nodes of all types
  29129. */
  29130. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29131. /**
  29132. * Get all child-meshes of this node
  29133. * @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)
  29134. * @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
  29135. * @returns an array of AbstractMesh
  29136. */
  29137. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29138. /**
  29139. * Get all direct children of this node
  29140. * @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
  29141. * @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)
  29142. * @returns an array of Node
  29143. */
  29144. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29145. /** @hidden */
  29146. _setReady(state: boolean): void;
  29147. /**
  29148. * Get an animation by name
  29149. * @param name defines the name of the animation to look for
  29150. * @returns null if not found else the requested animation
  29151. */
  29152. getAnimationByName(name: string): Nullable<Animation>;
  29153. /**
  29154. * Creates an animation range for this node
  29155. * @param name defines the name of the range
  29156. * @param from defines the starting key
  29157. * @param to defines the end key
  29158. */
  29159. createAnimationRange(name: string, from: number, to: number): void;
  29160. /**
  29161. * Delete a specific animation range
  29162. * @param name defines the name of the range to delete
  29163. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29164. */
  29165. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29166. /**
  29167. * Get an animation range by name
  29168. * @param name defines the name of the animation range to look for
  29169. * @returns null if not found else the requested animation range
  29170. */
  29171. getAnimationRange(name: string): Nullable<AnimationRange>;
  29172. /**
  29173. * Gets the list of all animation ranges defined on this node
  29174. * @returns an array
  29175. */
  29176. getAnimationRanges(): Nullable<AnimationRange>[];
  29177. /**
  29178. * Will start the animation sequence
  29179. * @param name defines the range frames for animation sequence
  29180. * @param loop defines if the animation should loop (false by default)
  29181. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29182. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29183. * @returns the object created for this animation. If range does not exist, it will return null
  29184. */
  29185. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29186. /**
  29187. * Serialize animation ranges into a JSON compatible object
  29188. * @returns serialization object
  29189. */
  29190. serializeAnimationRanges(): any;
  29191. /**
  29192. * Computes the world matrix of the node
  29193. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29194. * @returns the world matrix
  29195. */
  29196. computeWorldMatrix(force?: boolean): Matrix;
  29197. /**
  29198. * Releases resources associated with this node.
  29199. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29200. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29201. */
  29202. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29203. /**
  29204. * Parse animation range data from a serialization object and store them into a given node
  29205. * @param node defines where to store the animation ranges
  29206. * @param parsedNode defines the serialization object to read data from
  29207. * @param scene defines the hosting scene
  29208. */
  29209. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29210. /**
  29211. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29212. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29213. * @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
  29214. * @returns the new bounding vectors
  29215. */
  29216. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29217. min: Vector3;
  29218. max: Vector3;
  29219. };
  29220. }
  29221. }
  29222. declare module BABYLON {
  29223. /**
  29224. * @hidden
  29225. */
  29226. export class _IAnimationState {
  29227. key: number;
  29228. repeatCount: number;
  29229. workValue?: any;
  29230. loopMode?: number;
  29231. offsetValue?: any;
  29232. highLimitValue?: any;
  29233. }
  29234. /**
  29235. * Class used to store any kind of animation
  29236. */
  29237. export class Animation {
  29238. /**Name of the animation */
  29239. name: string;
  29240. /**Property to animate */
  29241. targetProperty: string;
  29242. /**The frames per second of the animation */
  29243. framePerSecond: number;
  29244. /**The data type of the animation */
  29245. dataType: number;
  29246. /**The loop mode of the animation */
  29247. loopMode?: number | undefined;
  29248. /**Specifies if blending should be enabled */
  29249. enableBlending?: boolean | undefined;
  29250. /**
  29251. * Use matrix interpolation instead of using direct key value when animating matrices
  29252. */
  29253. static AllowMatricesInterpolation: boolean;
  29254. /**
  29255. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29256. */
  29257. static AllowMatrixDecomposeForInterpolation: boolean;
  29258. /**
  29259. * Stores the key frames of the animation
  29260. */
  29261. private _keys;
  29262. /**
  29263. * Stores the easing function of the animation
  29264. */
  29265. private _easingFunction;
  29266. /**
  29267. * @hidden Internal use only
  29268. */
  29269. _runtimeAnimations: RuntimeAnimation[];
  29270. /**
  29271. * The set of event that will be linked to this animation
  29272. */
  29273. private _events;
  29274. /**
  29275. * Stores an array of target property paths
  29276. */
  29277. targetPropertyPath: string[];
  29278. /**
  29279. * Stores the blending speed of the animation
  29280. */
  29281. blendingSpeed: number;
  29282. /**
  29283. * Stores the animation ranges for the animation
  29284. */
  29285. private _ranges;
  29286. /**
  29287. * @hidden Internal use
  29288. */
  29289. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29290. /**
  29291. * Sets up an animation
  29292. * @param property The property to animate
  29293. * @param animationType The animation type to apply
  29294. * @param framePerSecond The frames per second of the animation
  29295. * @param easingFunction The easing function used in the animation
  29296. * @returns The created animation
  29297. */
  29298. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29299. /**
  29300. * Create and start an animation on a node
  29301. * @param name defines the name of the global animation that will be run on all nodes
  29302. * @param node defines the root node where the animation will take place
  29303. * @param targetProperty defines property to animate
  29304. * @param framePerSecond defines the number of frame per second yo use
  29305. * @param totalFrame defines the number of frames in total
  29306. * @param from defines the initial value
  29307. * @param to defines the final value
  29308. * @param loopMode defines which loop mode you want to use (off by default)
  29309. * @param easingFunction defines the easing function to use (linear by default)
  29310. * @param onAnimationEnd defines the callback to call when animation end
  29311. * @returns the animatable created for this animation
  29312. */
  29313. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29314. /**
  29315. * Create and start an animation on a node and its descendants
  29316. * @param name defines the name of the global animation that will be run on all nodes
  29317. * @param node defines the root node where the animation will take place
  29318. * @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
  29319. * @param targetProperty defines property to animate
  29320. * @param framePerSecond defines the number of frame per second to use
  29321. * @param totalFrame defines the number of frames in total
  29322. * @param from defines the initial value
  29323. * @param to defines the final value
  29324. * @param loopMode defines which loop mode you want to use (off by default)
  29325. * @param easingFunction defines the easing function to use (linear by default)
  29326. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29327. * @returns the list of animatables created for all nodes
  29328. * @example https://www.babylonjs-playground.com/#MH0VLI
  29329. */
  29330. 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[]>;
  29331. /**
  29332. * Creates a new animation, merges it with the existing animations and starts it
  29333. * @param name Name of the animation
  29334. * @param node Node which contains the scene that begins the animations
  29335. * @param targetProperty Specifies which property to animate
  29336. * @param framePerSecond The frames per second of the animation
  29337. * @param totalFrame The total number of frames
  29338. * @param from The frame at the beginning of the animation
  29339. * @param to The frame at the end of the animation
  29340. * @param loopMode Specifies the loop mode of the animation
  29341. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29342. * @param onAnimationEnd Callback to run once the animation is complete
  29343. * @returns Nullable animation
  29344. */
  29345. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29346. /**
  29347. * Transition property of an host to the target Value
  29348. * @param property The property to transition
  29349. * @param targetValue The target Value of the property
  29350. * @param host The object where the property to animate belongs
  29351. * @param scene Scene used to run the animation
  29352. * @param frameRate Framerate (in frame/s) to use
  29353. * @param transition The transition type we want to use
  29354. * @param duration The duration of the animation, in milliseconds
  29355. * @param onAnimationEnd Callback trigger at the end of the animation
  29356. * @returns Nullable animation
  29357. */
  29358. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29359. /**
  29360. * Return the array of runtime animations currently using this animation
  29361. */
  29362. get runtimeAnimations(): RuntimeAnimation[];
  29363. /**
  29364. * Specifies if any of the runtime animations are currently running
  29365. */
  29366. get hasRunningRuntimeAnimations(): boolean;
  29367. /**
  29368. * Initializes the animation
  29369. * @param name Name of the animation
  29370. * @param targetProperty Property to animate
  29371. * @param framePerSecond The frames per second of the animation
  29372. * @param dataType The data type of the animation
  29373. * @param loopMode The loop mode of the animation
  29374. * @param enableBlending Specifies if blending should be enabled
  29375. */
  29376. constructor(
  29377. /**Name of the animation */
  29378. name: string,
  29379. /**Property to animate */
  29380. targetProperty: string,
  29381. /**The frames per second of the animation */
  29382. framePerSecond: number,
  29383. /**The data type of the animation */
  29384. dataType: number,
  29385. /**The loop mode of the animation */
  29386. loopMode?: number | undefined,
  29387. /**Specifies if blending should be enabled */
  29388. enableBlending?: boolean | undefined);
  29389. /**
  29390. * Converts the animation to a string
  29391. * @param fullDetails support for multiple levels of logging within scene loading
  29392. * @returns String form of the animation
  29393. */
  29394. toString(fullDetails?: boolean): string;
  29395. /**
  29396. * Add an event to this animation
  29397. * @param event Event to add
  29398. */
  29399. addEvent(event: AnimationEvent): void;
  29400. /**
  29401. * Remove all events found at the given frame
  29402. * @param frame The frame to remove events from
  29403. */
  29404. removeEvents(frame: number): void;
  29405. /**
  29406. * Retrieves all the events from the animation
  29407. * @returns Events from the animation
  29408. */
  29409. getEvents(): AnimationEvent[];
  29410. /**
  29411. * Creates an animation range
  29412. * @param name Name of the animation range
  29413. * @param from Starting frame of the animation range
  29414. * @param to Ending frame of the animation
  29415. */
  29416. createRange(name: string, from: number, to: number): void;
  29417. /**
  29418. * Deletes an animation range by name
  29419. * @param name Name of the animation range to delete
  29420. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29421. */
  29422. deleteRange(name: string, deleteFrames?: boolean): void;
  29423. /**
  29424. * Gets the animation range by name, or null if not defined
  29425. * @param name Name of the animation range
  29426. * @returns Nullable animation range
  29427. */
  29428. getRange(name: string): Nullable<AnimationRange>;
  29429. /**
  29430. * Gets the key frames from the animation
  29431. * @returns The key frames of the animation
  29432. */
  29433. getKeys(): Array<IAnimationKey>;
  29434. /**
  29435. * Gets the highest frame rate of the animation
  29436. * @returns Highest frame rate of the animation
  29437. */
  29438. getHighestFrame(): number;
  29439. /**
  29440. * Gets the easing function of the animation
  29441. * @returns Easing function of the animation
  29442. */
  29443. getEasingFunction(): IEasingFunction;
  29444. /**
  29445. * Sets the easing function of the animation
  29446. * @param easingFunction A custom mathematical formula for animation
  29447. */
  29448. setEasingFunction(easingFunction: EasingFunction): void;
  29449. /**
  29450. * Interpolates a scalar linearly
  29451. * @param startValue Start value of the animation curve
  29452. * @param endValue End value of the animation curve
  29453. * @param gradient Scalar amount to interpolate
  29454. * @returns Interpolated scalar value
  29455. */
  29456. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29457. /**
  29458. * Interpolates a scalar cubically
  29459. * @param startValue Start value of the animation curve
  29460. * @param outTangent End tangent of the animation
  29461. * @param endValue End value of the animation curve
  29462. * @param inTangent Start tangent of the animation curve
  29463. * @param gradient Scalar amount to interpolate
  29464. * @returns Interpolated scalar value
  29465. */
  29466. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29467. /**
  29468. * Interpolates a quaternion using a spherical linear interpolation
  29469. * @param startValue Start value of the animation curve
  29470. * @param endValue End value of the animation curve
  29471. * @param gradient Scalar amount to interpolate
  29472. * @returns Interpolated quaternion value
  29473. */
  29474. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29475. /**
  29476. * Interpolates a quaternion cubically
  29477. * @param startValue Start value of the animation curve
  29478. * @param outTangent End tangent of the animation curve
  29479. * @param endValue End value of the animation curve
  29480. * @param inTangent Start tangent of the animation curve
  29481. * @param gradient Scalar amount to interpolate
  29482. * @returns Interpolated quaternion value
  29483. */
  29484. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29485. /**
  29486. * Interpolates a Vector3 linearl
  29487. * @param startValue Start value of the animation curve
  29488. * @param endValue End value of the animation curve
  29489. * @param gradient Scalar amount to interpolate
  29490. * @returns Interpolated scalar value
  29491. */
  29492. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29493. /**
  29494. * Interpolates a Vector3 cubically
  29495. * @param startValue Start value of the animation curve
  29496. * @param outTangent End tangent of the animation
  29497. * @param endValue End value of the animation curve
  29498. * @param inTangent Start tangent of the animation curve
  29499. * @param gradient Scalar amount to interpolate
  29500. * @returns InterpolatedVector3 value
  29501. */
  29502. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29503. /**
  29504. * Interpolates a Vector2 linearly
  29505. * @param startValue Start value of the animation curve
  29506. * @param endValue End value of the animation curve
  29507. * @param gradient Scalar amount to interpolate
  29508. * @returns Interpolated Vector2 value
  29509. */
  29510. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29511. /**
  29512. * Interpolates a Vector2 cubically
  29513. * @param startValue Start value of the animation curve
  29514. * @param outTangent End tangent of the animation
  29515. * @param endValue End value of the animation curve
  29516. * @param inTangent Start tangent of the animation curve
  29517. * @param gradient Scalar amount to interpolate
  29518. * @returns Interpolated Vector2 value
  29519. */
  29520. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29521. /**
  29522. * Interpolates a size linearly
  29523. * @param startValue Start value of the animation curve
  29524. * @param endValue End value of the animation curve
  29525. * @param gradient Scalar amount to interpolate
  29526. * @returns Interpolated Size value
  29527. */
  29528. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29529. /**
  29530. * Interpolates a Color3 linearly
  29531. * @param startValue Start value of the animation curve
  29532. * @param endValue End value of the animation curve
  29533. * @param gradient Scalar amount to interpolate
  29534. * @returns Interpolated Color3 value
  29535. */
  29536. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29537. /**
  29538. * Interpolates a Color4 linearly
  29539. * @param startValue Start value of the animation curve
  29540. * @param endValue End value of the animation curve
  29541. * @param gradient Scalar amount to interpolate
  29542. * @returns Interpolated Color3 value
  29543. */
  29544. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29545. /**
  29546. * @hidden Internal use only
  29547. */
  29548. _getKeyValue(value: any): any;
  29549. /**
  29550. * @hidden Internal use only
  29551. */
  29552. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29553. /**
  29554. * Defines the function to use to interpolate matrices
  29555. * @param startValue defines the start matrix
  29556. * @param endValue defines the end matrix
  29557. * @param gradient defines the gradient between both matrices
  29558. * @param result defines an optional target matrix where to store the interpolation
  29559. * @returns the interpolated matrix
  29560. */
  29561. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29562. /**
  29563. * Makes a copy of the animation
  29564. * @returns Cloned animation
  29565. */
  29566. clone(): Animation;
  29567. /**
  29568. * Sets the key frames of the animation
  29569. * @param values The animation key frames to set
  29570. */
  29571. setKeys(values: Array<IAnimationKey>): void;
  29572. /**
  29573. * Serializes the animation to an object
  29574. * @returns Serialized object
  29575. */
  29576. serialize(): any;
  29577. /**
  29578. * Float animation type
  29579. */
  29580. static readonly ANIMATIONTYPE_FLOAT: number;
  29581. /**
  29582. * Vector3 animation type
  29583. */
  29584. static readonly ANIMATIONTYPE_VECTOR3: number;
  29585. /**
  29586. * Quaternion animation type
  29587. */
  29588. static readonly ANIMATIONTYPE_QUATERNION: number;
  29589. /**
  29590. * Matrix animation type
  29591. */
  29592. static readonly ANIMATIONTYPE_MATRIX: number;
  29593. /**
  29594. * Color3 animation type
  29595. */
  29596. static readonly ANIMATIONTYPE_COLOR3: number;
  29597. /**
  29598. * Color3 animation type
  29599. */
  29600. static readonly ANIMATIONTYPE_COLOR4: number;
  29601. /**
  29602. * Vector2 animation type
  29603. */
  29604. static readonly ANIMATIONTYPE_VECTOR2: number;
  29605. /**
  29606. * Size animation type
  29607. */
  29608. static readonly ANIMATIONTYPE_SIZE: number;
  29609. /**
  29610. * Relative Loop Mode
  29611. */
  29612. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29613. /**
  29614. * Cycle Loop Mode
  29615. */
  29616. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29617. /**
  29618. * Constant Loop Mode
  29619. */
  29620. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29621. /** @hidden */
  29622. static _UniversalLerp(left: any, right: any, amount: number): any;
  29623. /**
  29624. * Parses an animation object and creates an animation
  29625. * @param parsedAnimation Parsed animation object
  29626. * @returns Animation object
  29627. */
  29628. static Parse(parsedAnimation: any): Animation;
  29629. /**
  29630. * Appends the serialized animations from the source animations
  29631. * @param source Source containing the animations
  29632. * @param destination Target to store the animations
  29633. */
  29634. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29635. }
  29636. }
  29637. declare module BABYLON {
  29638. /**
  29639. * Interface containing an array of animations
  29640. */
  29641. export interface IAnimatable {
  29642. /**
  29643. * Array of animations
  29644. */
  29645. animations: Nullable<Array<Animation>>;
  29646. }
  29647. }
  29648. declare module BABYLON {
  29649. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29650. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29651. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29652. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29653. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29654. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29655. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29656. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29657. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29658. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29659. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29660. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29661. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29662. /**
  29663. * Decorator used to define property that can be serialized as reference to a camera
  29664. * @param sourceName defines the name of the property to decorate
  29665. */
  29666. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29667. /**
  29668. * Class used to help serialization objects
  29669. */
  29670. export class SerializationHelper {
  29671. /** @hidden */
  29672. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29673. /** @hidden */
  29674. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29675. /** @hidden */
  29676. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29677. /** @hidden */
  29678. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29679. /**
  29680. * Appends the serialized animations from the source animations
  29681. * @param source Source containing the animations
  29682. * @param destination Target to store the animations
  29683. */
  29684. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29685. /**
  29686. * Static function used to serialized a specific entity
  29687. * @param entity defines the entity to serialize
  29688. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29689. * @returns a JSON compatible object representing the serialization of the entity
  29690. */
  29691. static Serialize<T>(entity: T, serializationObject?: any): any;
  29692. /**
  29693. * Creates a new entity from a serialization data object
  29694. * @param creationFunction defines a function used to instanciated the new entity
  29695. * @param source defines the source serialization data
  29696. * @param scene defines the hosting scene
  29697. * @param rootUrl defines the root url for resources
  29698. * @returns a new entity
  29699. */
  29700. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29701. /**
  29702. * Clones an object
  29703. * @param creationFunction defines the function used to instanciate the new object
  29704. * @param source defines the source object
  29705. * @returns the cloned object
  29706. */
  29707. static Clone<T>(creationFunction: () => T, source: T): T;
  29708. /**
  29709. * Instanciates a new object based on a source one (some data will be shared between both object)
  29710. * @param creationFunction defines the function used to instanciate the new object
  29711. * @param source defines the source object
  29712. * @returns the new object
  29713. */
  29714. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29715. }
  29716. }
  29717. declare module BABYLON {
  29718. /**
  29719. * Class used to manipulate GUIDs
  29720. */
  29721. export class GUID {
  29722. /**
  29723. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29724. * Be aware Math.random() could cause collisions, but:
  29725. * "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"
  29726. * @returns a pseudo random id
  29727. */
  29728. static RandomId(): string;
  29729. }
  29730. }
  29731. declare module BABYLON {
  29732. /**
  29733. * Base class of all the textures in babylon.
  29734. * It groups all the common properties the materials, post process, lights... might need
  29735. * in order to make a correct use of the texture.
  29736. */
  29737. export class BaseTexture implements IAnimatable {
  29738. /**
  29739. * Default anisotropic filtering level for the application.
  29740. * It is set to 4 as a good tradeoff between perf and quality.
  29741. */
  29742. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29743. /**
  29744. * Gets or sets the unique id of the texture
  29745. */
  29746. uniqueId: number;
  29747. /**
  29748. * Define the name of the texture.
  29749. */
  29750. name: string;
  29751. /**
  29752. * Gets or sets an object used to store user defined information.
  29753. */
  29754. metadata: any;
  29755. /**
  29756. * For internal use only. Please do not use.
  29757. */
  29758. reservedDataStore: any;
  29759. private _hasAlpha;
  29760. /**
  29761. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29762. */
  29763. set hasAlpha(value: boolean);
  29764. get hasAlpha(): boolean;
  29765. /**
  29766. * Defines if the alpha value should be determined via the rgb values.
  29767. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29768. */
  29769. getAlphaFromRGB: boolean;
  29770. /**
  29771. * Intensity or strength of the texture.
  29772. * It is commonly used by materials to fine tune the intensity of the texture
  29773. */
  29774. level: number;
  29775. /**
  29776. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29777. * This is part of the texture as textures usually maps to one uv set.
  29778. */
  29779. coordinatesIndex: number;
  29780. private _coordinatesMode;
  29781. /**
  29782. * How a texture is mapped.
  29783. *
  29784. * | Value | Type | Description |
  29785. * | ----- | ----------------------------------- | ----------- |
  29786. * | 0 | EXPLICIT_MODE | |
  29787. * | 1 | SPHERICAL_MODE | |
  29788. * | 2 | PLANAR_MODE | |
  29789. * | 3 | CUBIC_MODE | |
  29790. * | 4 | PROJECTION_MODE | |
  29791. * | 5 | SKYBOX_MODE | |
  29792. * | 6 | INVCUBIC_MODE | |
  29793. * | 7 | EQUIRECTANGULAR_MODE | |
  29794. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29795. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29796. */
  29797. set coordinatesMode(value: number);
  29798. get coordinatesMode(): number;
  29799. /**
  29800. * | Value | Type | Description |
  29801. * | ----- | ------------------ | ----------- |
  29802. * | 0 | CLAMP_ADDRESSMODE | |
  29803. * | 1 | WRAP_ADDRESSMODE | |
  29804. * | 2 | MIRROR_ADDRESSMODE | |
  29805. */
  29806. wrapU: number;
  29807. /**
  29808. * | Value | Type | Description |
  29809. * | ----- | ------------------ | ----------- |
  29810. * | 0 | CLAMP_ADDRESSMODE | |
  29811. * | 1 | WRAP_ADDRESSMODE | |
  29812. * | 2 | MIRROR_ADDRESSMODE | |
  29813. */
  29814. wrapV: number;
  29815. /**
  29816. * | Value | Type | Description |
  29817. * | ----- | ------------------ | ----------- |
  29818. * | 0 | CLAMP_ADDRESSMODE | |
  29819. * | 1 | WRAP_ADDRESSMODE | |
  29820. * | 2 | MIRROR_ADDRESSMODE | |
  29821. */
  29822. wrapR: number;
  29823. /**
  29824. * With compliant hardware and browser (supporting anisotropic filtering)
  29825. * this defines the level of anisotropic filtering in the texture.
  29826. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29827. */
  29828. anisotropicFilteringLevel: number;
  29829. /**
  29830. * Define if the texture is a cube texture or if false a 2d texture.
  29831. */
  29832. get isCube(): boolean;
  29833. set isCube(value: boolean);
  29834. /**
  29835. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29836. */
  29837. get is3D(): boolean;
  29838. set is3D(value: boolean);
  29839. /**
  29840. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29841. */
  29842. get is2DArray(): boolean;
  29843. set is2DArray(value: boolean);
  29844. /**
  29845. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29846. * HDR texture are usually stored in linear space.
  29847. * This only impacts the PBR and Background materials
  29848. */
  29849. gammaSpace: boolean;
  29850. /**
  29851. * Gets or sets whether or not the texture contains RGBD data.
  29852. */
  29853. get isRGBD(): boolean;
  29854. set isRGBD(value: boolean);
  29855. /**
  29856. * Is Z inverted in the texture (useful in a cube texture).
  29857. */
  29858. invertZ: boolean;
  29859. /**
  29860. * Are mip maps generated for this texture or not.
  29861. */
  29862. get noMipmap(): boolean;
  29863. /**
  29864. * @hidden
  29865. */
  29866. lodLevelInAlpha: boolean;
  29867. /**
  29868. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29869. */
  29870. get lodGenerationOffset(): number;
  29871. set lodGenerationOffset(value: number);
  29872. /**
  29873. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29874. */
  29875. get lodGenerationScale(): number;
  29876. set lodGenerationScale(value: number);
  29877. /**
  29878. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29879. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29880. * average roughness values.
  29881. */
  29882. get linearSpecularLOD(): boolean;
  29883. set linearSpecularLOD(value: boolean);
  29884. /**
  29885. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29886. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29887. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29888. */
  29889. get irradianceTexture(): Nullable<BaseTexture>;
  29890. set irradianceTexture(value: Nullable<BaseTexture>);
  29891. /**
  29892. * Define if the texture is a render target.
  29893. */
  29894. isRenderTarget: boolean;
  29895. /**
  29896. * Define the unique id of the texture in the scene.
  29897. */
  29898. get uid(): string;
  29899. /**
  29900. * Return a string representation of the texture.
  29901. * @returns the texture as a string
  29902. */
  29903. toString(): string;
  29904. /**
  29905. * Get the class name of the texture.
  29906. * @returns "BaseTexture"
  29907. */
  29908. getClassName(): string;
  29909. /**
  29910. * Define the list of animation attached to the texture.
  29911. */
  29912. animations: Animation[];
  29913. /**
  29914. * An event triggered when the texture is disposed.
  29915. */
  29916. onDisposeObservable: Observable<BaseTexture>;
  29917. private _onDisposeObserver;
  29918. /**
  29919. * Callback triggered when the texture has been disposed.
  29920. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29921. */
  29922. set onDispose(callback: () => void);
  29923. /**
  29924. * Define the current state of the loading sequence when in delayed load mode.
  29925. */
  29926. delayLoadState: number;
  29927. private _scene;
  29928. /** @hidden */
  29929. _texture: Nullable<InternalTexture>;
  29930. private _uid;
  29931. /**
  29932. * Define if the texture is preventinga material to render or not.
  29933. * If not and the texture is not ready, the engine will use a default black texture instead.
  29934. */
  29935. get isBlocking(): boolean;
  29936. /**
  29937. * Instantiates a new BaseTexture.
  29938. * Base class of all the textures in babylon.
  29939. * It groups all the common properties the materials, post process, lights... might need
  29940. * in order to make a correct use of the texture.
  29941. * @param scene Define the scene the texture blongs to
  29942. */
  29943. constructor(scene: Nullable<Scene>);
  29944. /**
  29945. * Get the scene the texture belongs to.
  29946. * @returns the scene or null if undefined
  29947. */
  29948. getScene(): Nullable<Scene>;
  29949. /**
  29950. * Get the texture transform matrix used to offset tile the texture for istance.
  29951. * @returns the transformation matrix
  29952. */
  29953. getTextureMatrix(): Matrix;
  29954. /**
  29955. * Get the texture reflection matrix used to rotate/transform the reflection.
  29956. * @returns the reflection matrix
  29957. */
  29958. getReflectionTextureMatrix(): Matrix;
  29959. /**
  29960. * Get the underlying lower level texture from Babylon.
  29961. * @returns the insternal texture
  29962. */
  29963. getInternalTexture(): Nullable<InternalTexture>;
  29964. /**
  29965. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29966. * @returns true if ready or not blocking
  29967. */
  29968. isReadyOrNotBlocking(): boolean;
  29969. /**
  29970. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29971. * @returns true if fully ready
  29972. */
  29973. isReady(): boolean;
  29974. private _cachedSize;
  29975. /**
  29976. * Get the size of the texture.
  29977. * @returns the texture size.
  29978. */
  29979. getSize(): ISize;
  29980. /**
  29981. * Get the base size of the texture.
  29982. * It can be different from the size if the texture has been resized for POT for instance
  29983. * @returns the base size
  29984. */
  29985. getBaseSize(): ISize;
  29986. /**
  29987. * Update the sampling mode of the texture.
  29988. * Default is Trilinear mode.
  29989. *
  29990. * | Value | Type | Description |
  29991. * | ----- | ------------------ | ----------- |
  29992. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29993. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29994. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29995. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29996. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29997. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29998. * | 7 | NEAREST_LINEAR | |
  29999. * | 8 | NEAREST_NEAREST | |
  30000. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30001. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30002. * | 11 | LINEAR_LINEAR | |
  30003. * | 12 | LINEAR_NEAREST | |
  30004. *
  30005. * > _mag_: magnification filter (close to the viewer)
  30006. * > _min_: minification filter (far from the viewer)
  30007. * > _mip_: filter used between mip map levels
  30008. *@param samplingMode Define the new sampling mode of the texture
  30009. */
  30010. updateSamplingMode(samplingMode: number): void;
  30011. /**
  30012. * Scales the texture if is `canRescale()`
  30013. * @param ratio the resize factor we want to use to rescale
  30014. */
  30015. scale(ratio: number): void;
  30016. /**
  30017. * Get if the texture can rescale.
  30018. */
  30019. get canRescale(): boolean;
  30020. /** @hidden */
  30021. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30022. /** @hidden */
  30023. _rebuild(): void;
  30024. /**
  30025. * Triggers the load sequence in delayed load mode.
  30026. */
  30027. delayLoad(): void;
  30028. /**
  30029. * Clones the texture.
  30030. * @returns the cloned texture
  30031. */
  30032. clone(): Nullable<BaseTexture>;
  30033. /**
  30034. * Get the texture underlying type (INT, FLOAT...)
  30035. */
  30036. get textureType(): number;
  30037. /**
  30038. * Get the texture underlying format (RGB, RGBA...)
  30039. */
  30040. get textureFormat(): number;
  30041. /**
  30042. * Indicates that textures need to be re-calculated for all materials
  30043. */
  30044. protected _markAllSubMeshesAsTexturesDirty(): void;
  30045. /**
  30046. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30047. * This will returns an RGBA array buffer containing either in values (0-255) or
  30048. * float values (0-1) depending of the underlying buffer type.
  30049. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30050. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30051. * @param buffer defines a user defined buffer to fill with data (can be null)
  30052. * @returns The Array buffer containing the pixels data.
  30053. */
  30054. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30055. /**
  30056. * Release and destroy the underlying lower level texture aka internalTexture.
  30057. */
  30058. releaseInternalTexture(): void;
  30059. /** @hidden */
  30060. get _lodTextureHigh(): Nullable<BaseTexture>;
  30061. /** @hidden */
  30062. get _lodTextureMid(): Nullable<BaseTexture>;
  30063. /** @hidden */
  30064. get _lodTextureLow(): Nullable<BaseTexture>;
  30065. /**
  30066. * Dispose the texture and release its associated resources.
  30067. */
  30068. dispose(): void;
  30069. /**
  30070. * Serialize the texture into a JSON representation that can be parsed later on.
  30071. * @returns the JSON representation of the texture
  30072. */
  30073. serialize(): any;
  30074. /**
  30075. * Helper function to be called back once a list of texture contains only ready textures.
  30076. * @param textures Define the list of textures to wait for
  30077. * @param callback Define the callback triggered once the entire list will be ready
  30078. */
  30079. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30080. }
  30081. }
  30082. declare module BABYLON {
  30083. /**
  30084. * Options to be used when creating an effect.
  30085. */
  30086. export interface IEffectCreationOptions {
  30087. /**
  30088. * Atrributes that will be used in the shader.
  30089. */
  30090. attributes: string[];
  30091. /**
  30092. * Uniform varible names that will be set in the shader.
  30093. */
  30094. uniformsNames: string[];
  30095. /**
  30096. * Uniform buffer variable names that will be set in the shader.
  30097. */
  30098. uniformBuffersNames: string[];
  30099. /**
  30100. * Sampler texture variable names that will be set in the shader.
  30101. */
  30102. samplers: string[];
  30103. /**
  30104. * Define statements that will be set in the shader.
  30105. */
  30106. defines: any;
  30107. /**
  30108. * Possible fallbacks for this effect to improve performance when needed.
  30109. */
  30110. fallbacks: Nullable<IEffectFallbacks>;
  30111. /**
  30112. * Callback that will be called when the shader is compiled.
  30113. */
  30114. onCompiled: Nullable<(effect: Effect) => void>;
  30115. /**
  30116. * Callback that will be called if an error occurs during shader compilation.
  30117. */
  30118. onError: Nullable<(effect: Effect, errors: string) => void>;
  30119. /**
  30120. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30121. */
  30122. indexParameters?: any;
  30123. /**
  30124. * Max number of lights that can be used in the shader.
  30125. */
  30126. maxSimultaneousLights?: number;
  30127. /**
  30128. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30129. */
  30130. transformFeedbackVaryings?: Nullable<string[]>;
  30131. }
  30132. /**
  30133. * Effect containing vertex and fragment shader that can be executed on an object.
  30134. */
  30135. export class Effect implements IDisposable {
  30136. /**
  30137. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30138. */
  30139. static ShadersRepository: string;
  30140. /**
  30141. * Enable logging of the shader code when a compilation error occurs
  30142. */
  30143. static LogShaderCodeOnCompilationError: boolean;
  30144. /**
  30145. * Name of the effect.
  30146. */
  30147. name: any;
  30148. /**
  30149. * String container all the define statements that should be set on the shader.
  30150. */
  30151. defines: string;
  30152. /**
  30153. * Callback that will be called when the shader is compiled.
  30154. */
  30155. onCompiled: Nullable<(effect: Effect) => void>;
  30156. /**
  30157. * Callback that will be called if an error occurs during shader compilation.
  30158. */
  30159. onError: Nullable<(effect: Effect, errors: string) => void>;
  30160. /**
  30161. * Callback that will be called when effect is bound.
  30162. */
  30163. onBind: Nullable<(effect: Effect) => void>;
  30164. /**
  30165. * Unique ID of the effect.
  30166. */
  30167. uniqueId: number;
  30168. /**
  30169. * Observable that will be called when the shader is compiled.
  30170. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30171. */
  30172. onCompileObservable: Observable<Effect>;
  30173. /**
  30174. * Observable that will be called if an error occurs during shader compilation.
  30175. */
  30176. onErrorObservable: Observable<Effect>;
  30177. /** @hidden */
  30178. _onBindObservable: Nullable<Observable<Effect>>;
  30179. /**
  30180. * @hidden
  30181. * Specifies if the effect was previously ready
  30182. */
  30183. _wasPreviouslyReady: boolean;
  30184. /**
  30185. * Observable that will be called when effect is bound.
  30186. */
  30187. get onBindObservable(): Observable<Effect>;
  30188. /** @hidden */
  30189. _bonesComputationForcedToCPU: boolean;
  30190. private static _uniqueIdSeed;
  30191. private _engine;
  30192. private _uniformBuffersNames;
  30193. private _uniformsNames;
  30194. private _samplerList;
  30195. private _samplers;
  30196. private _isReady;
  30197. private _compilationError;
  30198. private _allFallbacksProcessed;
  30199. private _attributesNames;
  30200. private _attributes;
  30201. private _attributeLocationByName;
  30202. private _uniforms;
  30203. /**
  30204. * Key for the effect.
  30205. * @hidden
  30206. */
  30207. _key: string;
  30208. private _indexParameters;
  30209. private _fallbacks;
  30210. private _vertexSourceCode;
  30211. private _fragmentSourceCode;
  30212. private _vertexSourceCodeOverride;
  30213. private _fragmentSourceCodeOverride;
  30214. private _transformFeedbackVaryings;
  30215. /**
  30216. * Compiled shader to webGL program.
  30217. * @hidden
  30218. */
  30219. _pipelineContext: Nullable<IPipelineContext>;
  30220. private _valueCache;
  30221. private static _baseCache;
  30222. /**
  30223. * Instantiates an effect.
  30224. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30225. * @param baseName Name of the effect.
  30226. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30227. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30228. * @param samplers List of sampler variables that will be passed to the shader.
  30229. * @param engine Engine to be used to render the effect
  30230. * @param defines Define statements to be added to the shader.
  30231. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30232. * @param onCompiled Callback that will be called when the shader is compiled.
  30233. * @param onError Callback that will be called if an error occurs during shader compilation.
  30234. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30235. */
  30236. 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);
  30237. private _useFinalCode;
  30238. /**
  30239. * Unique key for this effect
  30240. */
  30241. get key(): string;
  30242. /**
  30243. * If the effect has been compiled and prepared.
  30244. * @returns if the effect is compiled and prepared.
  30245. */
  30246. isReady(): boolean;
  30247. private _isReadyInternal;
  30248. /**
  30249. * The engine the effect was initialized with.
  30250. * @returns the engine.
  30251. */
  30252. getEngine(): Engine;
  30253. /**
  30254. * The pipeline context for this effect
  30255. * @returns the associated pipeline context
  30256. */
  30257. getPipelineContext(): Nullable<IPipelineContext>;
  30258. /**
  30259. * The set of names of attribute variables for the shader.
  30260. * @returns An array of attribute names.
  30261. */
  30262. getAttributesNames(): string[];
  30263. /**
  30264. * Returns the attribute at the given index.
  30265. * @param index The index of the attribute.
  30266. * @returns The location of the attribute.
  30267. */
  30268. getAttributeLocation(index: number): number;
  30269. /**
  30270. * Returns the attribute based on the name of the variable.
  30271. * @param name of the attribute to look up.
  30272. * @returns the attribute location.
  30273. */
  30274. getAttributeLocationByName(name: string): number;
  30275. /**
  30276. * The number of attributes.
  30277. * @returns the numnber of attributes.
  30278. */
  30279. getAttributesCount(): number;
  30280. /**
  30281. * Gets the index of a uniform variable.
  30282. * @param uniformName of the uniform to look up.
  30283. * @returns the index.
  30284. */
  30285. getUniformIndex(uniformName: string): number;
  30286. /**
  30287. * Returns the attribute based on the name of the variable.
  30288. * @param uniformName of the uniform to look up.
  30289. * @returns the location of the uniform.
  30290. */
  30291. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30292. /**
  30293. * Returns an array of sampler variable names
  30294. * @returns The array of sampler variable neames.
  30295. */
  30296. getSamplers(): string[];
  30297. /**
  30298. * The error from the last compilation.
  30299. * @returns the error string.
  30300. */
  30301. getCompilationError(): string;
  30302. /**
  30303. * Gets a boolean indicating that all fallbacks were used during compilation
  30304. * @returns true if all fallbacks were used
  30305. */
  30306. allFallbacksProcessed(): boolean;
  30307. /**
  30308. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30309. * @param func The callback to be used.
  30310. */
  30311. executeWhenCompiled(func: (effect: Effect) => void): void;
  30312. private _checkIsReady;
  30313. private _loadShader;
  30314. /**
  30315. * Recompiles the webGL program
  30316. * @param vertexSourceCode The source code for the vertex shader.
  30317. * @param fragmentSourceCode The source code for the fragment shader.
  30318. * @param onCompiled Callback called when completed.
  30319. * @param onError Callback called on error.
  30320. * @hidden
  30321. */
  30322. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30323. /**
  30324. * Prepares the effect
  30325. * @hidden
  30326. */
  30327. _prepareEffect(): void;
  30328. private _getShaderCodeAndErrorLine;
  30329. private _processCompilationErrors;
  30330. /**
  30331. * Checks if the effect is supported. (Must be called after compilation)
  30332. */
  30333. get isSupported(): boolean;
  30334. /**
  30335. * Binds a texture to the engine to be used as output of the shader.
  30336. * @param channel Name of the output variable.
  30337. * @param texture Texture to bind.
  30338. * @hidden
  30339. */
  30340. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30341. /**
  30342. * Sets a texture on the engine to be used in the shader.
  30343. * @param channel Name of the sampler variable.
  30344. * @param texture Texture to set.
  30345. */
  30346. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30347. /**
  30348. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30349. * @param channel Name of the sampler variable.
  30350. * @param texture Texture to set.
  30351. */
  30352. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30353. /**
  30354. * Sets an array of textures on the engine to be used in the shader.
  30355. * @param channel Name of the variable.
  30356. * @param textures Textures to set.
  30357. */
  30358. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30359. /**
  30360. * 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)
  30361. * @param channel Name of the sampler variable.
  30362. * @param postProcess Post process to get the input texture from.
  30363. */
  30364. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30365. /**
  30366. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30367. * 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)
  30368. * @param channel Name of the sampler variable.
  30369. * @param postProcess Post process to get the output texture from.
  30370. */
  30371. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30372. /** @hidden */
  30373. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30374. /** @hidden */
  30375. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30376. /** @hidden */
  30377. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30378. /** @hidden */
  30379. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30380. /**
  30381. * Binds a buffer to a uniform.
  30382. * @param buffer Buffer to bind.
  30383. * @param name Name of the uniform variable to bind to.
  30384. */
  30385. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30386. /**
  30387. * Binds block to a uniform.
  30388. * @param blockName Name of the block to bind.
  30389. * @param index Index to bind.
  30390. */
  30391. bindUniformBlock(blockName: string, index: number): void;
  30392. /**
  30393. * Sets an interger value on a uniform variable.
  30394. * @param uniformName Name of the variable.
  30395. * @param value Value to be set.
  30396. * @returns this effect.
  30397. */
  30398. setInt(uniformName: string, value: number): Effect;
  30399. /**
  30400. * Sets an int array on a uniform variable.
  30401. * @param uniformName Name of the variable.
  30402. * @param array array to be set.
  30403. * @returns this effect.
  30404. */
  30405. setIntArray(uniformName: string, array: Int32Array): Effect;
  30406. /**
  30407. * 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)
  30408. * @param uniformName Name of the variable.
  30409. * @param array array to be set.
  30410. * @returns this effect.
  30411. */
  30412. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30413. /**
  30414. * 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)
  30415. * @param uniformName Name of the variable.
  30416. * @param array array to be set.
  30417. * @returns this effect.
  30418. */
  30419. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30420. /**
  30421. * 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)
  30422. * @param uniformName Name of the variable.
  30423. * @param array array to be set.
  30424. * @returns this effect.
  30425. */
  30426. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30427. /**
  30428. * Sets an float array on a uniform variable.
  30429. * @param uniformName Name of the variable.
  30430. * @param array array to be set.
  30431. * @returns this effect.
  30432. */
  30433. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30434. /**
  30435. * 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)
  30436. * @param uniformName Name of the variable.
  30437. * @param array array to be set.
  30438. * @returns this effect.
  30439. */
  30440. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30441. /**
  30442. * 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)
  30443. * @param uniformName Name of the variable.
  30444. * @param array array to be set.
  30445. * @returns this effect.
  30446. */
  30447. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30448. /**
  30449. * 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)
  30450. * @param uniformName Name of the variable.
  30451. * @param array array to be set.
  30452. * @returns this effect.
  30453. */
  30454. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30455. /**
  30456. * Sets an array on a uniform variable.
  30457. * @param uniformName Name of the variable.
  30458. * @param array array to be set.
  30459. * @returns this effect.
  30460. */
  30461. setArray(uniformName: string, array: number[]): Effect;
  30462. /**
  30463. * 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)
  30464. * @param uniformName Name of the variable.
  30465. * @param array array to be set.
  30466. * @returns this effect.
  30467. */
  30468. setArray2(uniformName: string, array: number[]): Effect;
  30469. /**
  30470. * 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)
  30471. * @param uniformName Name of the variable.
  30472. * @param array array to be set.
  30473. * @returns this effect.
  30474. */
  30475. setArray3(uniformName: string, array: number[]): Effect;
  30476. /**
  30477. * 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)
  30478. * @param uniformName Name of the variable.
  30479. * @param array array to be set.
  30480. * @returns this effect.
  30481. */
  30482. setArray4(uniformName: string, array: number[]): Effect;
  30483. /**
  30484. * Sets matrices on a uniform variable.
  30485. * @param uniformName Name of the variable.
  30486. * @param matrices matrices to be set.
  30487. * @returns this effect.
  30488. */
  30489. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30490. /**
  30491. * Sets matrix on a uniform variable.
  30492. * @param uniformName Name of the variable.
  30493. * @param matrix matrix to be set.
  30494. * @returns this effect.
  30495. */
  30496. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30497. /**
  30498. * 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)
  30499. * @param uniformName Name of the variable.
  30500. * @param matrix matrix to be set.
  30501. * @returns this effect.
  30502. */
  30503. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30504. /**
  30505. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30506. * @param uniformName Name of the variable.
  30507. * @param matrix matrix to be set.
  30508. * @returns this effect.
  30509. */
  30510. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30511. /**
  30512. * Sets a float on a uniform variable.
  30513. * @param uniformName Name of the variable.
  30514. * @param value value to be set.
  30515. * @returns this effect.
  30516. */
  30517. setFloat(uniformName: string, value: number): Effect;
  30518. /**
  30519. * Sets a boolean on a uniform variable.
  30520. * @param uniformName Name of the variable.
  30521. * @param bool value to be set.
  30522. * @returns this effect.
  30523. */
  30524. setBool(uniformName: string, bool: boolean): Effect;
  30525. /**
  30526. * Sets a Vector2 on a uniform variable.
  30527. * @param uniformName Name of the variable.
  30528. * @param vector2 vector2 to be set.
  30529. * @returns this effect.
  30530. */
  30531. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30532. /**
  30533. * Sets a float2 on a uniform variable.
  30534. * @param uniformName Name of the variable.
  30535. * @param x First float in float2.
  30536. * @param y Second float in float2.
  30537. * @returns this effect.
  30538. */
  30539. setFloat2(uniformName: string, x: number, y: number): Effect;
  30540. /**
  30541. * Sets a Vector3 on a uniform variable.
  30542. * @param uniformName Name of the variable.
  30543. * @param vector3 Value to be set.
  30544. * @returns this effect.
  30545. */
  30546. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30547. /**
  30548. * Sets a float3 on a uniform variable.
  30549. * @param uniformName Name of the variable.
  30550. * @param x First float in float3.
  30551. * @param y Second float in float3.
  30552. * @param z Third float in float3.
  30553. * @returns this effect.
  30554. */
  30555. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30556. /**
  30557. * Sets a Vector4 on a uniform variable.
  30558. * @param uniformName Name of the variable.
  30559. * @param vector4 Value to be set.
  30560. * @returns this effect.
  30561. */
  30562. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30563. /**
  30564. * Sets a float4 on a uniform variable.
  30565. * @param uniformName Name of the variable.
  30566. * @param x First float in float4.
  30567. * @param y Second float in float4.
  30568. * @param z Third float in float4.
  30569. * @param w Fourth float in float4.
  30570. * @returns this effect.
  30571. */
  30572. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30573. /**
  30574. * Sets a Color3 on a uniform variable.
  30575. * @param uniformName Name of the variable.
  30576. * @param color3 Value to be set.
  30577. * @returns this effect.
  30578. */
  30579. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30580. /**
  30581. * Sets a Color4 on a uniform variable.
  30582. * @param uniformName Name of the variable.
  30583. * @param color3 Value to be set.
  30584. * @param alpha Alpha value to be set.
  30585. * @returns this effect.
  30586. */
  30587. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30588. /**
  30589. * Sets a Color4 on a uniform variable
  30590. * @param uniformName defines the name of the variable
  30591. * @param color4 defines the value to be set
  30592. * @returns this effect.
  30593. */
  30594. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30595. /** Release all associated resources */
  30596. dispose(): void;
  30597. /**
  30598. * This function will add a new shader to the shader store
  30599. * @param name the name of the shader
  30600. * @param pixelShader optional pixel shader content
  30601. * @param vertexShader optional vertex shader content
  30602. */
  30603. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30604. /**
  30605. * Store of each shader (The can be looked up using effect.key)
  30606. */
  30607. static ShadersStore: {
  30608. [key: string]: string;
  30609. };
  30610. /**
  30611. * Store of each included file for a shader (The can be looked up using effect.key)
  30612. */
  30613. static IncludesShadersStore: {
  30614. [key: string]: string;
  30615. };
  30616. /**
  30617. * Resets the cache of effects.
  30618. */
  30619. static ResetCache(): void;
  30620. }
  30621. }
  30622. declare module BABYLON {
  30623. /**
  30624. * Interface used to describe the capabilities of the engine relatively to the current browser
  30625. */
  30626. export interface EngineCapabilities {
  30627. /** Maximum textures units per fragment shader */
  30628. maxTexturesImageUnits: number;
  30629. /** Maximum texture units per vertex shader */
  30630. maxVertexTextureImageUnits: number;
  30631. /** Maximum textures units in the entire pipeline */
  30632. maxCombinedTexturesImageUnits: number;
  30633. /** Maximum texture size */
  30634. maxTextureSize: number;
  30635. /** Maximum texture samples */
  30636. maxSamples?: number;
  30637. /** Maximum cube texture size */
  30638. maxCubemapTextureSize: number;
  30639. /** Maximum render texture size */
  30640. maxRenderTextureSize: number;
  30641. /** Maximum number of vertex attributes */
  30642. maxVertexAttribs: number;
  30643. /** Maximum number of varyings */
  30644. maxVaryingVectors: number;
  30645. /** Maximum number of uniforms per vertex shader */
  30646. maxVertexUniformVectors: number;
  30647. /** Maximum number of uniforms per fragment shader */
  30648. maxFragmentUniformVectors: number;
  30649. /** Defines if standard derivates (dx/dy) are supported */
  30650. standardDerivatives: boolean;
  30651. /** Defines if s3tc texture compression is supported */
  30652. s3tc?: WEBGL_compressed_texture_s3tc;
  30653. /** Defines if pvrtc texture compression is supported */
  30654. pvrtc: any;
  30655. /** Defines if etc1 texture compression is supported */
  30656. etc1: any;
  30657. /** Defines if etc2 texture compression is supported */
  30658. etc2: any;
  30659. /** Defines if astc texture compression is supported */
  30660. astc: any;
  30661. /** Defines if float textures are supported */
  30662. textureFloat: boolean;
  30663. /** Defines if vertex array objects are supported */
  30664. vertexArrayObject: boolean;
  30665. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30666. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30667. /** Gets the maximum level of anisotropy supported */
  30668. maxAnisotropy: number;
  30669. /** Defines if instancing is supported */
  30670. instancedArrays: boolean;
  30671. /** Defines if 32 bits indices are supported */
  30672. uintIndices: boolean;
  30673. /** Defines if high precision shaders are supported */
  30674. highPrecisionShaderSupported: boolean;
  30675. /** Defines if depth reading in the fragment shader is supported */
  30676. fragmentDepthSupported: boolean;
  30677. /** Defines if float texture linear filtering is supported*/
  30678. textureFloatLinearFiltering: boolean;
  30679. /** Defines if rendering to float textures is supported */
  30680. textureFloatRender: boolean;
  30681. /** Defines if half float textures are supported*/
  30682. textureHalfFloat: boolean;
  30683. /** Defines if half float texture linear filtering is supported*/
  30684. textureHalfFloatLinearFiltering: boolean;
  30685. /** Defines if rendering to half float textures is supported */
  30686. textureHalfFloatRender: boolean;
  30687. /** Defines if textureLOD shader command is supported */
  30688. textureLOD: boolean;
  30689. /** Defines if draw buffers extension is supported */
  30690. drawBuffersExtension: boolean;
  30691. /** Defines if depth textures are supported */
  30692. depthTextureExtension: boolean;
  30693. /** Defines if float color buffer are supported */
  30694. colorBufferFloat: boolean;
  30695. /** Gets disjoint timer query extension (null if not supported) */
  30696. timerQuery?: EXT_disjoint_timer_query;
  30697. /** Defines if timestamp can be used with timer query */
  30698. canUseTimestampForTimerQuery: boolean;
  30699. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30700. multiview?: any;
  30701. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30702. oculusMultiview?: any;
  30703. /** Function used to let the system compiles shaders in background */
  30704. parallelShaderCompile?: {
  30705. COMPLETION_STATUS_KHR: number;
  30706. };
  30707. /** Max number of texture samples for MSAA */
  30708. maxMSAASamples: number;
  30709. /** Defines if the blend min max extension is supported */
  30710. blendMinMax: boolean;
  30711. }
  30712. }
  30713. declare module BABYLON {
  30714. /**
  30715. * @hidden
  30716. **/
  30717. export class DepthCullingState {
  30718. private _isDepthTestDirty;
  30719. private _isDepthMaskDirty;
  30720. private _isDepthFuncDirty;
  30721. private _isCullFaceDirty;
  30722. private _isCullDirty;
  30723. private _isZOffsetDirty;
  30724. private _isFrontFaceDirty;
  30725. private _depthTest;
  30726. private _depthMask;
  30727. private _depthFunc;
  30728. private _cull;
  30729. private _cullFace;
  30730. private _zOffset;
  30731. private _frontFace;
  30732. /**
  30733. * Initializes the state.
  30734. */
  30735. constructor();
  30736. get isDirty(): boolean;
  30737. get zOffset(): number;
  30738. set zOffset(value: number);
  30739. get cullFace(): Nullable<number>;
  30740. set cullFace(value: Nullable<number>);
  30741. get cull(): Nullable<boolean>;
  30742. set cull(value: Nullable<boolean>);
  30743. get depthFunc(): Nullable<number>;
  30744. set depthFunc(value: Nullable<number>);
  30745. get depthMask(): boolean;
  30746. set depthMask(value: boolean);
  30747. get depthTest(): boolean;
  30748. set depthTest(value: boolean);
  30749. get frontFace(): Nullable<number>;
  30750. set frontFace(value: Nullable<number>);
  30751. reset(): void;
  30752. apply(gl: WebGLRenderingContext): void;
  30753. }
  30754. }
  30755. declare module BABYLON {
  30756. /**
  30757. * @hidden
  30758. **/
  30759. export class StencilState {
  30760. /** 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 */
  30761. static readonly ALWAYS: number;
  30762. /** Passed to stencilOperation to specify that stencil value must be kept */
  30763. static readonly KEEP: number;
  30764. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30765. static readonly REPLACE: number;
  30766. private _isStencilTestDirty;
  30767. private _isStencilMaskDirty;
  30768. private _isStencilFuncDirty;
  30769. private _isStencilOpDirty;
  30770. private _stencilTest;
  30771. private _stencilMask;
  30772. private _stencilFunc;
  30773. private _stencilFuncRef;
  30774. private _stencilFuncMask;
  30775. private _stencilOpStencilFail;
  30776. private _stencilOpDepthFail;
  30777. private _stencilOpStencilDepthPass;
  30778. get isDirty(): boolean;
  30779. get stencilFunc(): number;
  30780. set stencilFunc(value: number);
  30781. get stencilFuncRef(): number;
  30782. set stencilFuncRef(value: number);
  30783. get stencilFuncMask(): number;
  30784. set stencilFuncMask(value: number);
  30785. get stencilOpStencilFail(): number;
  30786. set stencilOpStencilFail(value: number);
  30787. get stencilOpDepthFail(): number;
  30788. set stencilOpDepthFail(value: number);
  30789. get stencilOpStencilDepthPass(): number;
  30790. set stencilOpStencilDepthPass(value: number);
  30791. get stencilMask(): number;
  30792. set stencilMask(value: number);
  30793. get stencilTest(): boolean;
  30794. set stencilTest(value: boolean);
  30795. constructor();
  30796. reset(): void;
  30797. apply(gl: WebGLRenderingContext): void;
  30798. }
  30799. }
  30800. declare module BABYLON {
  30801. /**
  30802. * @hidden
  30803. **/
  30804. export class AlphaState {
  30805. private _isAlphaBlendDirty;
  30806. private _isBlendFunctionParametersDirty;
  30807. private _isBlendEquationParametersDirty;
  30808. private _isBlendConstantsDirty;
  30809. private _alphaBlend;
  30810. private _blendFunctionParameters;
  30811. private _blendEquationParameters;
  30812. private _blendConstants;
  30813. /**
  30814. * Initializes the state.
  30815. */
  30816. constructor();
  30817. get isDirty(): boolean;
  30818. get alphaBlend(): boolean;
  30819. set alphaBlend(value: boolean);
  30820. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30821. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30822. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30823. reset(): void;
  30824. apply(gl: WebGLRenderingContext): void;
  30825. }
  30826. }
  30827. declare module BABYLON {
  30828. /** @hidden */
  30829. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30830. attributeProcessor(attribute: string): string;
  30831. varyingProcessor(varying: string, isFragment: boolean): string;
  30832. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30833. }
  30834. }
  30835. declare module BABYLON {
  30836. /**
  30837. * Interface for attribute information associated with buffer instanciation
  30838. */
  30839. export interface InstancingAttributeInfo {
  30840. /**
  30841. * Name of the GLSL attribute
  30842. * if attribute index is not specified, this is used to retrieve the index from the effect
  30843. */
  30844. attributeName: string;
  30845. /**
  30846. * Index/offset of the attribute in the vertex shader
  30847. * if not specified, this will be computes from the name.
  30848. */
  30849. index?: number;
  30850. /**
  30851. * size of the attribute, 1, 2, 3 or 4
  30852. */
  30853. attributeSize: number;
  30854. /**
  30855. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30856. */
  30857. offset: number;
  30858. /**
  30859. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30860. * default to 1
  30861. */
  30862. divisor?: number;
  30863. /**
  30864. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30865. * default is FLOAT
  30866. */
  30867. attributeType?: number;
  30868. /**
  30869. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30870. */
  30871. normalized?: boolean;
  30872. }
  30873. }
  30874. declare module BABYLON {
  30875. interface ThinEngine {
  30876. /**
  30877. * Update a video texture
  30878. * @param texture defines the texture to update
  30879. * @param video defines the video element to use
  30880. * @param invertY defines if data must be stored with Y axis inverted
  30881. */
  30882. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30883. }
  30884. }
  30885. declare module BABYLON {
  30886. /**
  30887. * Settings for finer control over video usage
  30888. */
  30889. export interface VideoTextureSettings {
  30890. /**
  30891. * Applies `autoplay` to video, if specified
  30892. */
  30893. autoPlay?: boolean;
  30894. /**
  30895. * Applies `loop` to video, if specified
  30896. */
  30897. loop?: boolean;
  30898. /**
  30899. * Automatically updates internal texture from video at every frame in the render loop
  30900. */
  30901. autoUpdateTexture: boolean;
  30902. /**
  30903. * Image src displayed during the video loading or until the user interacts with the video.
  30904. */
  30905. poster?: string;
  30906. }
  30907. /**
  30908. * If you want to display a video in your scene, this is the special texture for that.
  30909. * This special texture works similar to other textures, with the exception of a few parameters.
  30910. * @see https://doc.babylonjs.com/how_to/video_texture
  30911. */
  30912. export class VideoTexture extends Texture {
  30913. /**
  30914. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30915. */
  30916. readonly autoUpdateTexture: boolean;
  30917. /**
  30918. * The video instance used by the texture internally
  30919. */
  30920. readonly video: HTMLVideoElement;
  30921. private _onUserActionRequestedObservable;
  30922. /**
  30923. * Event triggerd when a dom action is required by the user to play the video.
  30924. * This happens due to recent changes in browser policies preventing video to auto start.
  30925. */
  30926. get onUserActionRequestedObservable(): Observable<Texture>;
  30927. private _generateMipMaps;
  30928. private _engine;
  30929. private _stillImageCaptured;
  30930. private _displayingPosterTexture;
  30931. private _settings;
  30932. private _createInternalTextureOnEvent;
  30933. private _frameId;
  30934. private _currentSrc;
  30935. /**
  30936. * Creates a video texture.
  30937. * If you want to display a video in your scene, this is the special texture for that.
  30938. * This special texture works similar to other textures, with the exception of a few parameters.
  30939. * @see https://doc.babylonjs.com/how_to/video_texture
  30940. * @param name optional name, will detect from video source, if not defined
  30941. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30942. * @param scene is obviously the current scene.
  30943. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30944. * @param invertY is false by default but can be used to invert video on Y axis
  30945. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30946. * @param settings allows finer control over video usage
  30947. */
  30948. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30949. private _getName;
  30950. private _getVideo;
  30951. private _createInternalTexture;
  30952. private reset;
  30953. /**
  30954. * @hidden Internal method to initiate `update`.
  30955. */
  30956. _rebuild(): void;
  30957. /**
  30958. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30959. */
  30960. update(): void;
  30961. /**
  30962. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30963. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30964. */
  30965. updateTexture(isVisible: boolean): void;
  30966. protected _updateInternalTexture: () => void;
  30967. /**
  30968. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30969. * @param url New url.
  30970. */
  30971. updateURL(url: string): void;
  30972. /**
  30973. * Clones the texture.
  30974. * @returns the cloned texture
  30975. */
  30976. clone(): VideoTexture;
  30977. /**
  30978. * Dispose the texture and release its associated resources.
  30979. */
  30980. dispose(): void;
  30981. /**
  30982. * Creates a video texture straight from a stream.
  30983. * @param scene Define the scene the texture should be created in
  30984. * @param stream Define the stream the texture should be created from
  30985. * @returns The created video texture as a promise
  30986. */
  30987. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30988. /**
  30989. * Creates a video texture straight from your WebCam video feed.
  30990. * @param scene Define the scene the texture should be created in
  30991. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30992. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30993. * @returns The created video texture as a promise
  30994. */
  30995. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30996. minWidth: number;
  30997. maxWidth: number;
  30998. minHeight: number;
  30999. maxHeight: number;
  31000. deviceId: string;
  31001. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31002. /**
  31003. * Creates a video texture straight from your WebCam video feed.
  31004. * @param scene Define the scene the texture should be created in
  31005. * @param onReady Define a callback to triggered once the texture will be ready
  31006. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31007. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31008. */
  31009. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31010. minWidth: number;
  31011. maxWidth: number;
  31012. minHeight: number;
  31013. maxHeight: number;
  31014. deviceId: string;
  31015. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /**
  31020. * Defines the interface used by objects working like Scene
  31021. * @hidden
  31022. */
  31023. export interface ISceneLike {
  31024. _addPendingData(data: any): void;
  31025. _removePendingData(data: any): void;
  31026. offlineProvider: IOfflineProvider;
  31027. }
  31028. /** Interface defining initialization parameters for Engine class */
  31029. export interface EngineOptions extends WebGLContextAttributes {
  31030. /**
  31031. * Defines if the engine should no exceed a specified device ratio
  31032. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31033. */
  31034. limitDeviceRatio?: number;
  31035. /**
  31036. * Defines if webvr should be enabled automatically
  31037. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31038. */
  31039. autoEnableWebVR?: boolean;
  31040. /**
  31041. * Defines if webgl2 should be turned off even if supported
  31042. * @see http://doc.babylonjs.com/features/webgl2
  31043. */
  31044. disableWebGL2Support?: boolean;
  31045. /**
  31046. * Defines if webaudio should be initialized as well
  31047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31048. */
  31049. audioEngine?: boolean;
  31050. /**
  31051. * Defines if animations should run using a deterministic lock step
  31052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31053. */
  31054. deterministicLockstep?: boolean;
  31055. /** Defines the maximum steps to use with deterministic lock step mode */
  31056. lockstepMaxSteps?: number;
  31057. /** Defines the seconds between each deterministic lock step */
  31058. timeStep?: number;
  31059. /**
  31060. * Defines that engine should ignore context lost events
  31061. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31062. */
  31063. doNotHandleContextLost?: boolean;
  31064. /**
  31065. * Defines that engine should ignore modifying touch action attribute and style
  31066. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31067. */
  31068. doNotHandleTouchAction?: boolean;
  31069. /**
  31070. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31071. */
  31072. useHighPrecisionFloats?: boolean;
  31073. }
  31074. /**
  31075. * The base engine class (root of all engines)
  31076. */
  31077. export class ThinEngine {
  31078. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31079. static ExceptionList: ({
  31080. key: string;
  31081. capture: string;
  31082. captureConstraint: number;
  31083. targets: string[];
  31084. } | {
  31085. key: string;
  31086. capture: null;
  31087. captureConstraint: null;
  31088. targets: string[];
  31089. })[];
  31090. /** @hidden */
  31091. static _TextureLoaders: IInternalTextureLoader[];
  31092. /**
  31093. * Returns the current npm package of the sdk
  31094. */
  31095. static get NpmPackage(): string;
  31096. /**
  31097. * Returns the current version of the framework
  31098. */
  31099. static get Version(): string;
  31100. /**
  31101. * Returns a string describing the current engine
  31102. */
  31103. get description(): string;
  31104. /**
  31105. * Gets or sets the epsilon value used by collision engine
  31106. */
  31107. static CollisionsEpsilon: number;
  31108. /**
  31109. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31110. */
  31111. static get ShadersRepository(): string;
  31112. static set ShadersRepository(value: string);
  31113. /** @hidden */
  31114. _shaderProcessor: IShaderProcessor;
  31115. /**
  31116. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31117. */
  31118. forcePOTTextures: boolean;
  31119. /**
  31120. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31121. */
  31122. isFullscreen: boolean;
  31123. /**
  31124. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31125. */
  31126. cullBackFaces: boolean;
  31127. /**
  31128. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31129. */
  31130. renderEvenInBackground: boolean;
  31131. /**
  31132. * Gets or sets a boolean indicating that cache can be kept between frames
  31133. */
  31134. preventCacheWipeBetweenFrames: boolean;
  31135. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31136. validateShaderPrograms: boolean;
  31137. /**
  31138. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31139. * This can provide greater z depth for distant objects.
  31140. */
  31141. useReverseDepthBuffer: boolean;
  31142. /**
  31143. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31144. */
  31145. disableUniformBuffers: boolean;
  31146. /** @hidden */
  31147. _uniformBuffers: UniformBuffer[];
  31148. /**
  31149. * Gets a boolean indicating that the engine supports uniform buffers
  31150. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31151. */
  31152. get supportsUniformBuffers(): boolean;
  31153. /** @hidden */
  31154. _gl: WebGLRenderingContext;
  31155. /** @hidden */
  31156. _webGLVersion: number;
  31157. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31158. protected _windowIsBackground: boolean;
  31159. protected _creationOptions: EngineOptions;
  31160. protected _highPrecisionShadersAllowed: boolean;
  31161. /** @hidden */
  31162. get _shouldUseHighPrecisionShader(): boolean;
  31163. /**
  31164. * Gets a boolean indicating that only power of 2 textures are supported
  31165. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31166. */
  31167. get needPOTTextures(): boolean;
  31168. /** @hidden */
  31169. _badOS: boolean;
  31170. /** @hidden */
  31171. _badDesktopOS: boolean;
  31172. private _hardwareScalingLevel;
  31173. /** @hidden */
  31174. _caps: EngineCapabilities;
  31175. private _isStencilEnable;
  31176. private _glVersion;
  31177. private _glRenderer;
  31178. private _glVendor;
  31179. /** @hidden */
  31180. _videoTextureSupported: boolean;
  31181. protected _renderingQueueLaunched: boolean;
  31182. protected _activeRenderLoops: (() => void)[];
  31183. /**
  31184. * Observable signaled when a context lost event is raised
  31185. */
  31186. onContextLostObservable: Observable<ThinEngine>;
  31187. /**
  31188. * Observable signaled when a context restored event is raised
  31189. */
  31190. onContextRestoredObservable: Observable<ThinEngine>;
  31191. private _onContextLost;
  31192. private _onContextRestored;
  31193. protected _contextWasLost: boolean;
  31194. /** @hidden */
  31195. _doNotHandleContextLost: boolean;
  31196. /**
  31197. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31199. */
  31200. get doNotHandleContextLost(): boolean;
  31201. set doNotHandleContextLost(value: boolean);
  31202. /**
  31203. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31204. */
  31205. disableVertexArrayObjects: boolean;
  31206. /** @hidden */
  31207. protected _colorWrite: boolean;
  31208. /** @hidden */
  31209. protected _colorWriteChanged: boolean;
  31210. /** @hidden */
  31211. protected _depthCullingState: DepthCullingState;
  31212. /** @hidden */
  31213. protected _stencilState: StencilState;
  31214. /** @hidden */
  31215. _alphaState: AlphaState;
  31216. /** @hidden */
  31217. _alphaMode: number;
  31218. /** @hidden */
  31219. _alphaEquation: number;
  31220. /** @hidden */
  31221. _internalTexturesCache: InternalTexture[];
  31222. /** @hidden */
  31223. protected _activeChannel: number;
  31224. private _currentTextureChannel;
  31225. /** @hidden */
  31226. protected _boundTexturesCache: {
  31227. [key: string]: Nullable<InternalTexture>;
  31228. };
  31229. /** @hidden */
  31230. protected _currentEffect: Nullable<Effect>;
  31231. /** @hidden */
  31232. protected _currentProgram: Nullable<WebGLProgram>;
  31233. private _compiledEffects;
  31234. private _vertexAttribArraysEnabled;
  31235. /** @hidden */
  31236. protected _cachedViewport: Nullable<IViewportLike>;
  31237. private _cachedVertexArrayObject;
  31238. /** @hidden */
  31239. protected _cachedVertexBuffers: any;
  31240. /** @hidden */
  31241. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31242. /** @hidden */
  31243. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31244. /** @hidden */
  31245. _currentRenderTarget: Nullable<InternalTexture>;
  31246. private _uintIndicesCurrentlySet;
  31247. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31248. /** @hidden */
  31249. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31250. private _currentBufferPointers;
  31251. private _currentInstanceLocations;
  31252. private _currentInstanceBuffers;
  31253. private _textureUnits;
  31254. /** @hidden */
  31255. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31256. /** @hidden */
  31257. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31258. /** @hidden */
  31259. _boundRenderFunction: any;
  31260. private _vaoRecordInProgress;
  31261. private _mustWipeVertexAttributes;
  31262. private _emptyTexture;
  31263. private _emptyCubeTexture;
  31264. private _emptyTexture3D;
  31265. private _emptyTexture2DArray;
  31266. /** @hidden */
  31267. _frameHandler: number;
  31268. private _nextFreeTextureSlots;
  31269. private _maxSimultaneousTextures;
  31270. private _activeRequests;
  31271. /** @hidden */
  31272. _transformTextureUrl: Nullable<(url: string) => string>;
  31273. protected get _supportsHardwareTextureRescaling(): boolean;
  31274. private _framebufferDimensionsObject;
  31275. /**
  31276. * sets the object from which width and height will be taken from when getting render width and height
  31277. * Will fallback to the gl object
  31278. * @param dimensions the framebuffer width and height that will be used.
  31279. */
  31280. set framebufferDimensionsObject(dimensions: Nullable<{
  31281. framebufferWidth: number;
  31282. framebufferHeight: number;
  31283. }>);
  31284. /**
  31285. * Gets the current viewport
  31286. */
  31287. get currentViewport(): Nullable<IViewportLike>;
  31288. /**
  31289. * Gets the default empty texture
  31290. */
  31291. get emptyTexture(): InternalTexture;
  31292. /**
  31293. * Gets the default empty 3D texture
  31294. */
  31295. get emptyTexture3D(): InternalTexture;
  31296. /**
  31297. * Gets the default empty 2D array texture
  31298. */
  31299. get emptyTexture2DArray(): InternalTexture;
  31300. /**
  31301. * Gets the default empty cube texture
  31302. */
  31303. get emptyCubeTexture(): InternalTexture;
  31304. /**
  31305. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31306. */
  31307. readonly premultipliedAlpha: boolean;
  31308. /**
  31309. * Observable event triggered before each texture is initialized
  31310. */
  31311. onBeforeTextureInitObservable: Observable<Texture>;
  31312. /**
  31313. * Creates a new engine
  31314. * @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
  31315. * @param antialias defines enable antialiasing (default: false)
  31316. * @param options defines further options to be sent to the getContext() function
  31317. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31318. */
  31319. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31320. private _rebuildInternalTextures;
  31321. private _rebuildEffects;
  31322. /**
  31323. * Gets a boolean indicating if all created effects are ready
  31324. * @returns true if all effects are ready
  31325. */
  31326. areAllEffectsReady(): boolean;
  31327. protected _rebuildBuffers(): void;
  31328. protected _initGLContext(): void;
  31329. /**
  31330. * Gets version of the current webGL context
  31331. */
  31332. get webGLVersion(): number;
  31333. /**
  31334. * Gets a string idenfifying the name of the class
  31335. * @returns "Engine" string
  31336. */
  31337. getClassName(): string;
  31338. /**
  31339. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31340. */
  31341. get isStencilEnable(): boolean;
  31342. /** @hidden */
  31343. _prepareWorkingCanvas(): void;
  31344. /**
  31345. * Reset the texture cache to empty state
  31346. */
  31347. resetTextureCache(): void;
  31348. /**
  31349. * Gets an object containing information about the current webGL context
  31350. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31351. */
  31352. getGlInfo(): {
  31353. vendor: string;
  31354. renderer: string;
  31355. version: string;
  31356. };
  31357. /**
  31358. * Defines the hardware scaling level.
  31359. * By default the hardware scaling level is computed from the window device ratio.
  31360. * 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.
  31361. * @param level defines the level to use
  31362. */
  31363. setHardwareScalingLevel(level: number): void;
  31364. /**
  31365. * Gets the current hardware scaling level.
  31366. * By default the hardware scaling level is computed from the window device ratio.
  31367. * 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.
  31368. * @returns a number indicating the current hardware scaling level
  31369. */
  31370. getHardwareScalingLevel(): number;
  31371. /**
  31372. * Gets the list of loaded textures
  31373. * @returns an array containing all loaded textures
  31374. */
  31375. getLoadedTexturesCache(): InternalTexture[];
  31376. /**
  31377. * Gets the object containing all engine capabilities
  31378. * @returns the EngineCapabilities object
  31379. */
  31380. getCaps(): EngineCapabilities;
  31381. /**
  31382. * stop executing a render loop function and remove it from the execution array
  31383. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31384. */
  31385. stopRenderLoop(renderFunction?: () => void): void;
  31386. /** @hidden */
  31387. _renderLoop(): void;
  31388. /**
  31389. * Gets the HTML canvas attached with the current webGL context
  31390. * @returns a HTML canvas
  31391. */
  31392. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31393. /**
  31394. * Gets host window
  31395. * @returns the host window object
  31396. */
  31397. getHostWindow(): Nullable<Window>;
  31398. /**
  31399. * Gets the current render width
  31400. * @param useScreen defines if screen size must be used (or the current render target if any)
  31401. * @returns a number defining the current render width
  31402. */
  31403. getRenderWidth(useScreen?: boolean): number;
  31404. /**
  31405. * Gets the current render height
  31406. * @param useScreen defines if screen size must be used (or the current render target if any)
  31407. * @returns a number defining the current render height
  31408. */
  31409. getRenderHeight(useScreen?: boolean): number;
  31410. /**
  31411. * Can be used to override the current requestAnimationFrame requester.
  31412. * @hidden
  31413. */
  31414. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31415. /**
  31416. * Register and execute a render loop. The engine can have more than one render function
  31417. * @param renderFunction defines the function to continuously execute
  31418. */
  31419. runRenderLoop(renderFunction: () => void): void;
  31420. /**
  31421. * Clear the current render buffer or the current render target (if any is set up)
  31422. * @param color defines the color to use
  31423. * @param backBuffer defines if the back buffer must be cleared
  31424. * @param depth defines if the depth buffer must be cleared
  31425. * @param stencil defines if the stencil buffer must be cleared
  31426. */
  31427. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31428. private _viewportCached;
  31429. /** @hidden */
  31430. _viewport(x: number, y: number, width: number, height: number): void;
  31431. /**
  31432. * Set the WebGL's viewport
  31433. * @param viewport defines the viewport element to be used
  31434. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31435. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31436. */
  31437. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31438. /**
  31439. * Begin a new frame
  31440. */
  31441. beginFrame(): void;
  31442. /**
  31443. * Enf the current frame
  31444. */
  31445. endFrame(): void;
  31446. /**
  31447. * Resize the view according to the canvas' size
  31448. */
  31449. resize(): void;
  31450. /**
  31451. * Force a specific size of the canvas
  31452. * @param width defines the new canvas' width
  31453. * @param height defines the new canvas' height
  31454. */
  31455. setSize(width: number, height: number): void;
  31456. /**
  31457. * Binds the frame buffer to the specified texture.
  31458. * @param texture The texture to render to or null for the default canvas
  31459. * @param faceIndex The face of the texture to render to in case of cube texture
  31460. * @param requiredWidth The width of the target to render to
  31461. * @param requiredHeight The height of the target to render to
  31462. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31463. * @param lodLevel defines the lod level to bind to the frame buffer
  31464. * @param layer defines the 2d array index to bind to frame buffer to
  31465. */
  31466. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31467. /** @hidden */
  31468. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31469. /**
  31470. * Unbind the current render target texture from the webGL context
  31471. * @param texture defines the render target texture to unbind
  31472. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31473. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31474. */
  31475. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31476. /**
  31477. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31478. */
  31479. flushFramebuffer(): void;
  31480. /**
  31481. * Unbind the current render target and bind the default framebuffer
  31482. */
  31483. restoreDefaultFramebuffer(): void;
  31484. /** @hidden */
  31485. protected _resetVertexBufferBinding(): void;
  31486. /**
  31487. * Creates a vertex buffer
  31488. * @param data the data for the vertex buffer
  31489. * @returns the new WebGL static buffer
  31490. */
  31491. createVertexBuffer(data: DataArray): DataBuffer;
  31492. private _createVertexBuffer;
  31493. /**
  31494. * Creates a dynamic vertex buffer
  31495. * @param data the data for the dynamic vertex buffer
  31496. * @returns the new WebGL dynamic buffer
  31497. */
  31498. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31499. protected _resetIndexBufferBinding(): void;
  31500. /**
  31501. * Creates a new index buffer
  31502. * @param indices defines the content of the index buffer
  31503. * @param updatable defines if the index buffer must be updatable
  31504. * @returns a new webGL buffer
  31505. */
  31506. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31507. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31508. /**
  31509. * Bind a webGL buffer to the webGL context
  31510. * @param buffer defines the buffer to bind
  31511. */
  31512. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31513. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31514. private bindBuffer;
  31515. /**
  31516. * update the bound buffer with the given data
  31517. * @param data defines the data to update
  31518. */
  31519. updateArrayBuffer(data: Float32Array): void;
  31520. private _vertexAttribPointer;
  31521. /** @hidden */
  31522. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31523. private _bindVertexBuffersAttributes;
  31524. /**
  31525. * Records a vertex array object
  31526. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31527. * @param vertexBuffers defines the list of vertex buffers to store
  31528. * @param indexBuffer defines the index buffer to store
  31529. * @param effect defines the effect to store
  31530. * @returns the new vertex array object
  31531. */
  31532. recordVertexArrayObject(vertexBuffers: {
  31533. [key: string]: VertexBuffer;
  31534. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31535. /**
  31536. * Bind a specific vertex array object
  31537. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31538. * @param vertexArrayObject defines the vertex array object to bind
  31539. * @param indexBuffer defines the index buffer to bind
  31540. */
  31541. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31542. /**
  31543. * Bind webGl buffers directly to the webGL context
  31544. * @param vertexBuffer defines the vertex buffer to bind
  31545. * @param indexBuffer defines the index buffer to bind
  31546. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31547. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31548. * @param effect defines the effect associated with the vertex buffer
  31549. */
  31550. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31551. private _unbindVertexArrayObject;
  31552. /**
  31553. * Bind a list of vertex buffers to the webGL context
  31554. * @param vertexBuffers defines the list of vertex buffers to bind
  31555. * @param indexBuffer defines the index buffer to bind
  31556. * @param effect defines the effect associated with the vertex buffers
  31557. */
  31558. bindBuffers(vertexBuffers: {
  31559. [key: string]: Nullable<VertexBuffer>;
  31560. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31561. /**
  31562. * Unbind all instance attributes
  31563. */
  31564. unbindInstanceAttributes(): void;
  31565. /**
  31566. * Release and free the memory of a vertex array object
  31567. * @param vao defines the vertex array object to delete
  31568. */
  31569. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31570. /** @hidden */
  31571. _releaseBuffer(buffer: DataBuffer): boolean;
  31572. protected _deleteBuffer(buffer: DataBuffer): void;
  31573. /**
  31574. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31575. * @param instancesBuffer defines the webGL buffer to update and bind
  31576. * @param data defines the data to store in the buffer
  31577. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31578. */
  31579. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31580. /**
  31581. * Bind the content of a webGL buffer used with instantiation
  31582. * @param instancesBuffer defines the webGL buffer to bind
  31583. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31584. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31585. */
  31586. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31587. /**
  31588. * Disable the instance attribute corresponding to the name in parameter
  31589. * @param name defines the name of the attribute to disable
  31590. */
  31591. disableInstanceAttributeByName(name: string): void;
  31592. /**
  31593. * Disable the instance attribute corresponding to the location in parameter
  31594. * @param attributeLocation defines the attribute location of the attribute to disable
  31595. */
  31596. disableInstanceAttribute(attributeLocation: number): void;
  31597. /**
  31598. * Disable the attribute corresponding to the location in parameter
  31599. * @param attributeLocation defines the attribute location of the attribute to disable
  31600. */
  31601. disableAttributeByIndex(attributeLocation: number): void;
  31602. /**
  31603. * Send a draw order
  31604. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31605. * @param indexStart defines the starting index
  31606. * @param indexCount defines the number of index to draw
  31607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31608. */
  31609. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31610. /**
  31611. * Draw a list of points
  31612. * @param verticesStart defines the index of first vertex to draw
  31613. * @param verticesCount defines the count of vertices to draw
  31614. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31615. */
  31616. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31617. /**
  31618. * Draw a list of unindexed primitives
  31619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31620. * @param verticesStart defines the index of first vertex to draw
  31621. * @param verticesCount defines the count of vertices to draw
  31622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31623. */
  31624. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31625. /**
  31626. * Draw a list of indexed primitives
  31627. * @param fillMode defines the primitive to use
  31628. * @param indexStart defines the starting index
  31629. * @param indexCount defines the number of index to draw
  31630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31631. */
  31632. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31633. /**
  31634. * Draw a list of unindexed primitives
  31635. * @param fillMode defines the primitive to use
  31636. * @param verticesStart defines the index of first vertex to draw
  31637. * @param verticesCount defines the count of vertices to draw
  31638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31639. */
  31640. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31641. private _drawMode;
  31642. /** @hidden */
  31643. protected _reportDrawCall(): void;
  31644. /** @hidden */
  31645. _releaseEffect(effect: Effect): void;
  31646. /** @hidden */
  31647. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31648. /**
  31649. * Create a new effect (used to store vertex/fragment shaders)
  31650. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31651. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31652. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31653. * @param samplers defines an array of string used to represent textures
  31654. * @param defines defines the string containing the defines to use to compile the shaders
  31655. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31656. * @param onCompiled defines a function to call when the effect creation is successful
  31657. * @param onError defines a function to call when the effect creation has failed
  31658. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31659. * @returns the new Effect
  31660. */
  31661. 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;
  31662. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31663. private _compileShader;
  31664. private _compileRawShader;
  31665. /** @hidden */
  31666. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31667. /**
  31668. * Directly creates a webGL program
  31669. * @param pipelineContext defines the pipeline context to attach to
  31670. * @param vertexCode defines the vertex shader code to use
  31671. * @param fragmentCode defines the fragment shader code to use
  31672. * @param context defines the webGL context to use (if not set, the current one will be used)
  31673. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31674. * @returns the new webGL program
  31675. */
  31676. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31677. /**
  31678. * Creates a webGL program
  31679. * @param pipelineContext defines the pipeline context to attach to
  31680. * @param vertexCode defines the vertex shader code to use
  31681. * @param fragmentCode defines the fragment shader code to use
  31682. * @param defines defines the string containing the defines to use to compile the shaders
  31683. * @param context defines the webGL context to use (if not set, the current one will be used)
  31684. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31685. * @returns the new webGL program
  31686. */
  31687. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31688. /**
  31689. * Creates a new pipeline context
  31690. * @returns the new pipeline
  31691. */
  31692. createPipelineContext(): IPipelineContext;
  31693. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31694. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31695. /** @hidden */
  31696. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31697. /** @hidden */
  31698. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31699. /** @hidden */
  31700. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31701. /**
  31702. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31703. * @param pipelineContext defines the pipeline context to use
  31704. * @param uniformsNames defines the list of uniform names
  31705. * @returns an array of webGL uniform locations
  31706. */
  31707. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31708. /**
  31709. * Gets the lsit of active attributes for a given webGL program
  31710. * @param pipelineContext defines the pipeline context to use
  31711. * @param attributesNames defines the list of attribute names to get
  31712. * @returns an array of indices indicating the offset of each attribute
  31713. */
  31714. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31715. /**
  31716. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31717. * @param effect defines the effect to activate
  31718. */
  31719. enableEffect(effect: Nullable<Effect>): void;
  31720. /**
  31721. * Set the value of an uniform to a number (int)
  31722. * @param uniform defines the webGL uniform location where to store the value
  31723. * @param value defines the int number to store
  31724. */
  31725. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31726. /**
  31727. * Set the value of an uniform to an array of int32
  31728. * @param uniform defines the webGL uniform location where to store the value
  31729. * @param array defines the array of int32 to store
  31730. */
  31731. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31732. /**
  31733. * Set the value of an uniform to an array of int32 (stored as vec2)
  31734. * @param uniform defines the webGL uniform location where to store the value
  31735. * @param array defines the array of int32 to store
  31736. */
  31737. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31738. /**
  31739. * Set the value of an uniform to an array of int32 (stored as vec3)
  31740. * @param uniform defines the webGL uniform location where to store the value
  31741. * @param array defines the array of int32 to store
  31742. */
  31743. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31744. /**
  31745. * Set the value of an uniform to an array of int32 (stored as vec4)
  31746. * @param uniform defines the webGL uniform location where to store the value
  31747. * @param array defines the array of int32 to store
  31748. */
  31749. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31750. /**
  31751. * Set the value of an uniform to an array of number
  31752. * @param uniform defines the webGL uniform location where to store the value
  31753. * @param array defines the array of number to store
  31754. */
  31755. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31756. /**
  31757. * Set the value of an uniform to an array of number (stored as vec2)
  31758. * @param uniform defines the webGL uniform location where to store the value
  31759. * @param array defines the array of number to store
  31760. */
  31761. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31762. /**
  31763. * Set the value of an uniform to an array of number (stored as vec3)
  31764. * @param uniform defines the webGL uniform location where to store the value
  31765. * @param array defines the array of number to store
  31766. */
  31767. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31768. /**
  31769. * Set the value of an uniform to an array of number (stored as vec4)
  31770. * @param uniform defines the webGL uniform location where to store the value
  31771. * @param array defines the array of number to store
  31772. */
  31773. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31774. /**
  31775. * Set the value of an uniform to an array of float32 (stored as matrices)
  31776. * @param uniform defines the webGL uniform location where to store the value
  31777. * @param matrices defines the array of float32 to store
  31778. */
  31779. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31780. /**
  31781. * Set the value of an uniform to a matrix (3x3)
  31782. * @param uniform defines the webGL uniform location where to store the value
  31783. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31784. */
  31785. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31786. /**
  31787. * Set the value of an uniform to a matrix (2x2)
  31788. * @param uniform defines the webGL uniform location where to store the value
  31789. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31790. */
  31791. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31792. /**
  31793. * Set the value of an uniform to a number (float)
  31794. * @param uniform defines the webGL uniform location where to store the value
  31795. * @param value defines the float number to store
  31796. */
  31797. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31798. /**
  31799. * Set the value of an uniform to a vec2
  31800. * @param uniform defines the webGL uniform location where to store the value
  31801. * @param x defines the 1st component of the value
  31802. * @param y defines the 2nd component of the value
  31803. */
  31804. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31805. /**
  31806. * Set the value of an uniform to a vec3
  31807. * @param uniform defines the webGL uniform location where to store the value
  31808. * @param x defines the 1st component of the value
  31809. * @param y defines the 2nd component of the value
  31810. * @param z defines the 3rd component of the value
  31811. */
  31812. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31813. /**
  31814. * Set the value of an uniform to a vec4
  31815. * @param uniform defines the webGL uniform location where to store the value
  31816. * @param x defines the 1st component of the value
  31817. * @param y defines the 2nd component of the value
  31818. * @param z defines the 3rd component of the value
  31819. * @param w defines the 4th component of the value
  31820. */
  31821. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31822. /**
  31823. * Apply all cached states (depth, culling, stencil and alpha)
  31824. */
  31825. applyStates(): void;
  31826. /**
  31827. * Enable or disable color writing
  31828. * @param enable defines the state to set
  31829. */
  31830. setColorWrite(enable: boolean): void;
  31831. /**
  31832. * Gets a boolean indicating if color writing is enabled
  31833. * @returns the current color writing state
  31834. */
  31835. getColorWrite(): boolean;
  31836. /**
  31837. * Gets the depth culling state manager
  31838. */
  31839. get depthCullingState(): DepthCullingState;
  31840. /**
  31841. * Gets the alpha state manager
  31842. */
  31843. get alphaState(): AlphaState;
  31844. /**
  31845. * Gets the stencil state manager
  31846. */
  31847. get stencilState(): StencilState;
  31848. /**
  31849. * Clears the list of texture accessible through engine.
  31850. * This can help preventing texture load conflict due to name collision.
  31851. */
  31852. clearInternalTexturesCache(): void;
  31853. /**
  31854. * Force the entire cache to be cleared
  31855. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31856. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31857. */
  31858. wipeCaches(bruteForce?: boolean): void;
  31859. /** @hidden */
  31860. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31861. min: number;
  31862. mag: number;
  31863. };
  31864. /** @hidden */
  31865. _createTexture(): WebGLTexture;
  31866. /**
  31867. * Usually called from Texture.ts.
  31868. * Passed information to create a WebGLTexture
  31869. * @param url defines a value which contains one of the following:
  31870. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31871. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31872. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31873. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31874. * @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)
  31875. * @param scene needed for loading to the correct scene
  31876. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31877. * @param onLoad optional callback to be called upon successful completion
  31878. * @param onError optional callback to be called upon failure
  31879. * @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
  31880. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31881. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31882. * @param forcedExtension defines the extension to use to pick the right loader
  31883. * @param mimeType defines an optional mime type
  31884. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31885. */
  31886. 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;
  31887. /**
  31888. * Loads an image as an HTMLImageElement.
  31889. * @param input url string, ArrayBuffer, or Blob to load
  31890. * @param onLoad callback called when the image successfully loads
  31891. * @param onError callback called when the image fails to load
  31892. * @param offlineProvider offline provider for caching
  31893. * @param mimeType optional mime type
  31894. * @returns the HTMLImageElement of the loaded image
  31895. * @hidden
  31896. */
  31897. 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>;
  31898. /**
  31899. * @hidden
  31900. */
  31901. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31902. /**
  31903. * Creates a raw texture
  31904. * @param data defines the data to store in the texture
  31905. * @param width defines the width of the texture
  31906. * @param height defines the height of the texture
  31907. * @param format defines the format of the data
  31908. * @param generateMipMaps defines if the engine should generate the mip levels
  31909. * @param invertY defines if data must be stored with Y axis inverted
  31910. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31911. * @param compression defines the compression used (null by default)
  31912. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31913. * @returns the raw texture inside an InternalTexture
  31914. */
  31915. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31916. /**
  31917. * Creates a new raw cube texture
  31918. * @param data defines the array of data to use to create each face
  31919. * @param size defines the size of the textures
  31920. * @param format defines the format of the data
  31921. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31922. * @param generateMipMaps defines if the engine should generate the mip levels
  31923. * @param invertY defines if data must be stored with Y axis inverted
  31924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31925. * @param compression defines the compression used (null by default)
  31926. * @returns the cube texture as an InternalTexture
  31927. */
  31928. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31929. /**
  31930. * Creates a new raw 3D texture
  31931. * @param data defines the data used to create the texture
  31932. * @param width defines the width of the texture
  31933. * @param height defines the height of the texture
  31934. * @param depth defines the depth of the texture
  31935. * @param format defines the format of the texture
  31936. * @param generateMipMaps defines if the engine must generate mip levels
  31937. * @param invertY defines if data must be stored with Y axis inverted
  31938. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31939. * @param compression defines the compressed used (can be null)
  31940. * @param textureType defines the compressed used (can be null)
  31941. * @returns a new raw 3D texture (stored in an InternalTexture)
  31942. */
  31943. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31944. /**
  31945. * Creates a new raw 2D array texture
  31946. * @param data defines the data used to create the texture
  31947. * @param width defines the width of the texture
  31948. * @param height defines the height of the texture
  31949. * @param depth defines the number of layers of the texture
  31950. * @param format defines the format of the texture
  31951. * @param generateMipMaps defines if the engine must generate mip levels
  31952. * @param invertY defines if data must be stored with Y axis inverted
  31953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31954. * @param compression defines the compressed used (can be null)
  31955. * @param textureType defines the compressed used (can be null)
  31956. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31957. */
  31958. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31959. private _unpackFlipYCached;
  31960. /**
  31961. * In case you are sharing the context with other applications, it might
  31962. * be interested to not cache the unpack flip y state to ensure a consistent
  31963. * value would be set.
  31964. */
  31965. enableUnpackFlipYCached: boolean;
  31966. /** @hidden */
  31967. _unpackFlipY(value: boolean): void;
  31968. /** @hidden */
  31969. _getUnpackAlignement(): number;
  31970. private _getTextureTarget;
  31971. /**
  31972. * Update the sampling mode of a given texture
  31973. * @param samplingMode defines the required sampling mode
  31974. * @param texture defines the texture to update
  31975. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31976. */
  31977. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31978. /**
  31979. * Update the sampling mode of a given texture
  31980. * @param texture defines the texture to update
  31981. * @param wrapU defines the texture wrap mode of the u coordinates
  31982. * @param wrapV defines the texture wrap mode of the v coordinates
  31983. * @param wrapR defines the texture wrap mode of the r coordinates
  31984. */
  31985. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31986. /** @hidden */
  31987. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31988. width: number;
  31989. height: number;
  31990. layers?: number;
  31991. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31992. /** @hidden */
  31993. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31994. /** @hidden */
  31995. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31996. /**
  31997. * Update a portion of an internal texture
  31998. * @param texture defines the texture to update
  31999. * @param imageData defines the data to store into the texture
  32000. * @param xOffset defines the x coordinates of the update rectangle
  32001. * @param yOffset defines the y coordinates of the update rectangle
  32002. * @param width defines the width of the update rectangle
  32003. * @param height defines the height of the update rectangle
  32004. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32005. * @param lod defines the lod level to update (0 by default)
  32006. */
  32007. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32008. /** @hidden */
  32009. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32010. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32011. private _prepareWebGLTexture;
  32012. /** @hidden */
  32013. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32014. private _getDepthStencilBuffer;
  32015. /** @hidden */
  32016. _releaseFramebufferObjects(texture: InternalTexture): void;
  32017. /** @hidden */
  32018. _releaseTexture(texture: InternalTexture): void;
  32019. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32020. protected _setProgram(program: WebGLProgram): void;
  32021. protected _boundUniforms: {
  32022. [key: number]: WebGLUniformLocation;
  32023. };
  32024. /**
  32025. * Binds an effect to the webGL context
  32026. * @param effect defines the effect to bind
  32027. */
  32028. bindSamplers(effect: Effect): void;
  32029. private _activateCurrentTexture;
  32030. /** @hidden */
  32031. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32032. /** @hidden */
  32033. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32034. /**
  32035. * Unbind all textures from the webGL context
  32036. */
  32037. unbindAllTextures(): void;
  32038. /**
  32039. * Sets a texture to the according uniform.
  32040. * @param channel The texture channel
  32041. * @param uniform The uniform to set
  32042. * @param texture The texture to apply
  32043. */
  32044. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32045. private _bindSamplerUniformToChannel;
  32046. private _getTextureWrapMode;
  32047. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32048. /**
  32049. * Sets an array of texture to the webGL context
  32050. * @param channel defines the channel where the texture array must be set
  32051. * @param uniform defines the associated uniform location
  32052. * @param textures defines the array of textures to bind
  32053. */
  32054. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32055. /** @hidden */
  32056. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32057. private _setTextureParameterFloat;
  32058. private _setTextureParameterInteger;
  32059. /**
  32060. * Unbind all vertex attributes from the webGL context
  32061. */
  32062. unbindAllAttributes(): void;
  32063. /**
  32064. * 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
  32065. */
  32066. releaseEffects(): void;
  32067. /**
  32068. * Dispose and release all associated resources
  32069. */
  32070. dispose(): void;
  32071. /**
  32072. * Attach a new callback raised when context lost event is fired
  32073. * @param callback defines the callback to call
  32074. */
  32075. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32076. /**
  32077. * Attach a new callback raised when context restored event is fired
  32078. * @param callback defines the callback to call
  32079. */
  32080. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32081. /**
  32082. * Get the current error code of the webGL context
  32083. * @returns the error code
  32084. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32085. */
  32086. getError(): number;
  32087. private _canRenderToFloatFramebuffer;
  32088. private _canRenderToHalfFloatFramebuffer;
  32089. private _canRenderToFramebuffer;
  32090. /** @hidden */
  32091. _getWebGLTextureType(type: number): number;
  32092. /** @hidden */
  32093. _getInternalFormat(format: number): number;
  32094. /** @hidden */
  32095. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32096. /** @hidden */
  32097. _getRGBAMultiSampleBufferFormat(type: number): number;
  32098. /** @hidden */
  32099. _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;
  32100. /**
  32101. * Loads a file from a url
  32102. * @param url url to load
  32103. * @param onSuccess callback called when the file successfully loads
  32104. * @param onProgress callback called while file is loading (if the server supports this mode)
  32105. * @param offlineProvider defines the offline provider for caching
  32106. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32107. * @param onError callback called when the file fails to load
  32108. * @returns a file request object
  32109. * @hidden
  32110. */
  32111. 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;
  32112. /**
  32113. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32114. * @param x defines the x coordinate of the rectangle where pixels must be read
  32115. * @param y defines the y coordinate of the rectangle where pixels must be read
  32116. * @param width defines the width of the rectangle where pixels must be read
  32117. * @param height defines the height of the rectangle where pixels must be read
  32118. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32119. * @returns a Uint8Array containing RGBA colors
  32120. */
  32121. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32122. private static _isSupported;
  32123. /**
  32124. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32125. * @returns true if the engine can be created
  32126. * @ignorenaming
  32127. */
  32128. static isSupported(): boolean;
  32129. /**
  32130. * Find the next highest power of two.
  32131. * @param x Number to start search from.
  32132. * @return Next highest power of two.
  32133. */
  32134. static CeilingPOT(x: number): number;
  32135. /**
  32136. * Find the next lowest power of two.
  32137. * @param x Number to start search from.
  32138. * @return Next lowest power of two.
  32139. */
  32140. static FloorPOT(x: number): number;
  32141. /**
  32142. * Find the nearest power of two.
  32143. * @param x Number to start search from.
  32144. * @return Next nearest power of two.
  32145. */
  32146. static NearestPOT(x: number): number;
  32147. /**
  32148. * Get the closest exponent of two
  32149. * @param value defines the value to approximate
  32150. * @param max defines the maximum value to return
  32151. * @param mode defines how to define the closest value
  32152. * @returns closest exponent of two of the given value
  32153. */
  32154. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32155. /**
  32156. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32157. * @param func - the function to be called
  32158. * @param requester - the object that will request the next frame. Falls back to window.
  32159. * @returns frame number
  32160. */
  32161. static QueueNewFrame(func: () => void, requester?: any): number;
  32162. /**
  32163. * Gets host document
  32164. * @returns the host document object
  32165. */
  32166. getHostDocument(): Nullable<Document>;
  32167. }
  32168. }
  32169. declare module BABYLON {
  32170. /**
  32171. * Class representing spherical harmonics coefficients to the 3rd degree
  32172. */
  32173. export class SphericalHarmonics {
  32174. /**
  32175. * Defines whether or not the harmonics have been prescaled for rendering.
  32176. */
  32177. preScaled: boolean;
  32178. /**
  32179. * The l0,0 coefficients of the spherical harmonics
  32180. */
  32181. l00: Vector3;
  32182. /**
  32183. * The l1,-1 coefficients of the spherical harmonics
  32184. */
  32185. l1_1: Vector3;
  32186. /**
  32187. * The l1,0 coefficients of the spherical harmonics
  32188. */
  32189. l10: Vector3;
  32190. /**
  32191. * The l1,1 coefficients of the spherical harmonics
  32192. */
  32193. l11: Vector3;
  32194. /**
  32195. * The l2,-2 coefficients of the spherical harmonics
  32196. */
  32197. l2_2: Vector3;
  32198. /**
  32199. * The l2,-1 coefficients of the spherical harmonics
  32200. */
  32201. l2_1: Vector3;
  32202. /**
  32203. * The l2,0 coefficients of the spherical harmonics
  32204. */
  32205. l20: Vector3;
  32206. /**
  32207. * The l2,1 coefficients of the spherical harmonics
  32208. */
  32209. l21: Vector3;
  32210. /**
  32211. * The l2,2 coefficients of the spherical harmonics
  32212. */
  32213. l22: Vector3;
  32214. /**
  32215. * Adds a light to the spherical harmonics
  32216. * @param direction the direction of the light
  32217. * @param color the color of the light
  32218. * @param deltaSolidAngle the delta solid angle of the light
  32219. */
  32220. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32221. /**
  32222. * Scales the spherical harmonics by the given amount
  32223. * @param scale the amount to scale
  32224. */
  32225. scaleInPlace(scale: number): void;
  32226. /**
  32227. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32228. *
  32229. * ```
  32230. * E_lm = A_l * L_lm
  32231. * ```
  32232. *
  32233. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32234. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32235. * the scaling factors are given in equation 9.
  32236. */
  32237. convertIncidentRadianceToIrradiance(): void;
  32238. /**
  32239. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32240. *
  32241. * ```
  32242. * L = (1/pi) * E * rho
  32243. * ```
  32244. *
  32245. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32246. */
  32247. convertIrradianceToLambertianRadiance(): void;
  32248. /**
  32249. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32250. * required operations at run time.
  32251. *
  32252. * This is simply done by scaling back the SH with Ylm constants parameter.
  32253. * The trigonometric part being applied by the shader at run time.
  32254. */
  32255. preScaleForRendering(): void;
  32256. /**
  32257. * Constructs a spherical harmonics from an array.
  32258. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32259. * @returns the spherical harmonics
  32260. */
  32261. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32262. /**
  32263. * Gets the spherical harmonics from polynomial
  32264. * @param polynomial the spherical polynomial
  32265. * @returns the spherical harmonics
  32266. */
  32267. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32268. }
  32269. /**
  32270. * Class representing spherical polynomial coefficients to the 3rd degree
  32271. */
  32272. export class SphericalPolynomial {
  32273. private _harmonics;
  32274. /**
  32275. * The spherical harmonics used to create the polynomials.
  32276. */
  32277. get preScaledHarmonics(): SphericalHarmonics;
  32278. /**
  32279. * The x coefficients of the spherical polynomial
  32280. */
  32281. x: Vector3;
  32282. /**
  32283. * The y coefficients of the spherical polynomial
  32284. */
  32285. y: Vector3;
  32286. /**
  32287. * The z coefficients of the spherical polynomial
  32288. */
  32289. z: Vector3;
  32290. /**
  32291. * The xx coefficients of the spherical polynomial
  32292. */
  32293. xx: Vector3;
  32294. /**
  32295. * The yy coefficients of the spherical polynomial
  32296. */
  32297. yy: Vector3;
  32298. /**
  32299. * The zz coefficients of the spherical polynomial
  32300. */
  32301. zz: Vector3;
  32302. /**
  32303. * The xy coefficients of the spherical polynomial
  32304. */
  32305. xy: Vector3;
  32306. /**
  32307. * The yz coefficients of the spherical polynomial
  32308. */
  32309. yz: Vector3;
  32310. /**
  32311. * The zx coefficients of the spherical polynomial
  32312. */
  32313. zx: Vector3;
  32314. /**
  32315. * Adds an ambient color to the spherical polynomial
  32316. * @param color the color to add
  32317. */
  32318. addAmbient(color: Color3): void;
  32319. /**
  32320. * Scales the spherical polynomial by the given amount
  32321. * @param scale the amount to scale
  32322. */
  32323. scaleInPlace(scale: number): void;
  32324. /**
  32325. * Gets the spherical polynomial from harmonics
  32326. * @param harmonics the spherical harmonics
  32327. * @returns the spherical polynomial
  32328. */
  32329. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32330. /**
  32331. * Constructs a spherical polynomial from an array.
  32332. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32333. * @returns the spherical polynomial
  32334. */
  32335. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32336. }
  32337. }
  32338. declare module BABYLON {
  32339. /**
  32340. * Defines the source of the internal texture
  32341. */
  32342. export enum InternalTextureSource {
  32343. /**
  32344. * The source of the texture data is unknown
  32345. */
  32346. Unknown = 0,
  32347. /**
  32348. * Texture data comes from an URL
  32349. */
  32350. Url = 1,
  32351. /**
  32352. * Texture data is only used for temporary storage
  32353. */
  32354. Temp = 2,
  32355. /**
  32356. * Texture data comes from raw data (ArrayBuffer)
  32357. */
  32358. Raw = 3,
  32359. /**
  32360. * Texture content is dynamic (video or dynamic texture)
  32361. */
  32362. Dynamic = 4,
  32363. /**
  32364. * Texture content is generated by rendering to it
  32365. */
  32366. RenderTarget = 5,
  32367. /**
  32368. * Texture content is part of a multi render target process
  32369. */
  32370. MultiRenderTarget = 6,
  32371. /**
  32372. * Texture data comes from a cube data file
  32373. */
  32374. Cube = 7,
  32375. /**
  32376. * Texture data comes from a raw cube data
  32377. */
  32378. CubeRaw = 8,
  32379. /**
  32380. * Texture data come from a prefiltered cube data file
  32381. */
  32382. CubePrefiltered = 9,
  32383. /**
  32384. * Texture content is raw 3D data
  32385. */
  32386. Raw3D = 10,
  32387. /**
  32388. * Texture content is raw 2D array data
  32389. */
  32390. Raw2DArray = 11,
  32391. /**
  32392. * Texture content is a depth texture
  32393. */
  32394. Depth = 12,
  32395. /**
  32396. * Texture data comes from a raw cube data encoded with RGBD
  32397. */
  32398. CubeRawRGBD = 13
  32399. }
  32400. /**
  32401. * Class used to store data associated with WebGL texture data for the engine
  32402. * This class should not be used directly
  32403. */
  32404. export class InternalTexture {
  32405. /** @hidden */
  32406. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32407. /**
  32408. * Defines if the texture is ready
  32409. */
  32410. isReady: boolean;
  32411. /**
  32412. * Defines if the texture is a cube texture
  32413. */
  32414. isCube: boolean;
  32415. /**
  32416. * Defines if the texture contains 3D data
  32417. */
  32418. is3D: boolean;
  32419. /**
  32420. * Defines if the texture contains 2D array data
  32421. */
  32422. is2DArray: boolean;
  32423. /**
  32424. * Defines if the texture contains multiview data
  32425. */
  32426. isMultiview: boolean;
  32427. /**
  32428. * Gets the URL used to load this texture
  32429. */
  32430. url: string;
  32431. /**
  32432. * Gets the sampling mode of the texture
  32433. */
  32434. samplingMode: number;
  32435. /**
  32436. * Gets a boolean indicating if the texture needs mipmaps generation
  32437. */
  32438. generateMipMaps: boolean;
  32439. /**
  32440. * Gets the number of samples used by the texture (WebGL2+ only)
  32441. */
  32442. samples: number;
  32443. /**
  32444. * Gets the type of the texture (int, float...)
  32445. */
  32446. type: number;
  32447. /**
  32448. * Gets the format of the texture (RGB, RGBA...)
  32449. */
  32450. format: number;
  32451. /**
  32452. * Observable called when the texture is loaded
  32453. */
  32454. onLoadedObservable: Observable<InternalTexture>;
  32455. /**
  32456. * Gets the width of the texture
  32457. */
  32458. width: number;
  32459. /**
  32460. * Gets the height of the texture
  32461. */
  32462. height: number;
  32463. /**
  32464. * Gets the depth of the texture
  32465. */
  32466. depth: number;
  32467. /**
  32468. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32469. */
  32470. baseWidth: number;
  32471. /**
  32472. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32473. */
  32474. baseHeight: number;
  32475. /**
  32476. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32477. */
  32478. baseDepth: number;
  32479. /**
  32480. * Gets a boolean indicating if the texture is inverted on Y axis
  32481. */
  32482. invertY: boolean;
  32483. /** @hidden */
  32484. _invertVScale: boolean;
  32485. /** @hidden */
  32486. _associatedChannel: number;
  32487. /** @hidden */
  32488. _source: InternalTextureSource;
  32489. /** @hidden */
  32490. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32491. /** @hidden */
  32492. _bufferView: Nullable<ArrayBufferView>;
  32493. /** @hidden */
  32494. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32495. /** @hidden */
  32496. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32497. /** @hidden */
  32498. _size: number;
  32499. /** @hidden */
  32500. _extension: string;
  32501. /** @hidden */
  32502. _files: Nullable<string[]>;
  32503. /** @hidden */
  32504. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32505. /** @hidden */
  32506. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32507. /** @hidden */
  32508. _framebuffer: Nullable<WebGLFramebuffer>;
  32509. /** @hidden */
  32510. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32511. /** @hidden */
  32512. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32513. /** @hidden */
  32514. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32515. /** @hidden */
  32516. _attachments: Nullable<number[]>;
  32517. /** @hidden */
  32518. _cachedCoordinatesMode: Nullable<number>;
  32519. /** @hidden */
  32520. _cachedWrapU: Nullable<number>;
  32521. /** @hidden */
  32522. _cachedWrapV: Nullable<number>;
  32523. /** @hidden */
  32524. _cachedWrapR: Nullable<number>;
  32525. /** @hidden */
  32526. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32527. /** @hidden */
  32528. _isDisabled: boolean;
  32529. /** @hidden */
  32530. _compression: Nullable<string>;
  32531. /** @hidden */
  32532. _generateStencilBuffer: boolean;
  32533. /** @hidden */
  32534. _generateDepthBuffer: boolean;
  32535. /** @hidden */
  32536. _comparisonFunction: number;
  32537. /** @hidden */
  32538. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32539. /** @hidden */
  32540. _lodGenerationScale: number;
  32541. /** @hidden */
  32542. _lodGenerationOffset: number;
  32543. /** @hidden */
  32544. _depthStencilTexture: Nullable<InternalTexture>;
  32545. /** @hidden */
  32546. _colorTextureArray: Nullable<WebGLTexture>;
  32547. /** @hidden */
  32548. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32549. /** @hidden */
  32550. _lodTextureHigh: Nullable<BaseTexture>;
  32551. /** @hidden */
  32552. _lodTextureMid: Nullable<BaseTexture>;
  32553. /** @hidden */
  32554. _lodTextureLow: Nullable<BaseTexture>;
  32555. /** @hidden */
  32556. _isRGBD: boolean;
  32557. /** @hidden */
  32558. _linearSpecularLOD: boolean;
  32559. /** @hidden */
  32560. _irradianceTexture: Nullable<BaseTexture>;
  32561. /** @hidden */
  32562. _webGLTexture: Nullable<WebGLTexture>;
  32563. /** @hidden */
  32564. _references: number;
  32565. private _engine;
  32566. /**
  32567. * Gets the Engine the texture belongs to.
  32568. * @returns The babylon engine
  32569. */
  32570. getEngine(): ThinEngine;
  32571. /**
  32572. * Gets the data source type of the texture
  32573. */
  32574. get source(): InternalTextureSource;
  32575. /**
  32576. * Creates a new InternalTexture
  32577. * @param engine defines the engine to use
  32578. * @param source defines the type of data that will be used
  32579. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32580. */
  32581. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32582. /**
  32583. * Increments the number of references (ie. the number of Texture that point to it)
  32584. */
  32585. incrementReferences(): void;
  32586. /**
  32587. * Change the size of the texture (not the size of the content)
  32588. * @param width defines the new width
  32589. * @param height defines the new height
  32590. * @param depth defines the new depth (1 by default)
  32591. */
  32592. updateSize(width: int, height: int, depth?: int): void;
  32593. /** @hidden */
  32594. _rebuild(): void;
  32595. /** @hidden */
  32596. _swapAndDie(target: InternalTexture): void;
  32597. /**
  32598. * Dispose the current allocated resources
  32599. */
  32600. dispose(): void;
  32601. }
  32602. }
  32603. declare module BABYLON {
  32604. /**
  32605. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32607. */
  32608. export class Analyser {
  32609. /**
  32610. * Gets or sets the smoothing
  32611. * @ignorenaming
  32612. */
  32613. SMOOTHING: number;
  32614. /**
  32615. * Gets or sets the FFT table size
  32616. * @ignorenaming
  32617. */
  32618. FFT_SIZE: number;
  32619. /**
  32620. * Gets or sets the bar graph amplitude
  32621. * @ignorenaming
  32622. */
  32623. BARGRAPHAMPLITUDE: number;
  32624. /**
  32625. * Gets or sets the position of the debug canvas
  32626. * @ignorenaming
  32627. */
  32628. DEBUGCANVASPOS: {
  32629. x: number;
  32630. y: number;
  32631. };
  32632. /**
  32633. * Gets or sets the debug canvas size
  32634. * @ignorenaming
  32635. */
  32636. DEBUGCANVASSIZE: {
  32637. width: number;
  32638. height: number;
  32639. };
  32640. private _byteFreqs;
  32641. private _byteTime;
  32642. private _floatFreqs;
  32643. private _webAudioAnalyser;
  32644. private _debugCanvas;
  32645. private _debugCanvasContext;
  32646. private _scene;
  32647. private _registerFunc;
  32648. private _audioEngine;
  32649. /**
  32650. * Creates a new analyser
  32651. * @param scene defines hosting scene
  32652. */
  32653. constructor(scene: Scene);
  32654. /**
  32655. * Get the number of data values you will have to play with for the visualization
  32656. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32657. * @returns a number
  32658. */
  32659. getFrequencyBinCount(): number;
  32660. /**
  32661. * Gets the current frequency data as a byte array
  32662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32663. * @returns a Uint8Array
  32664. */
  32665. getByteFrequencyData(): Uint8Array;
  32666. /**
  32667. * Gets the current waveform as a byte array
  32668. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32669. * @returns a Uint8Array
  32670. */
  32671. getByteTimeDomainData(): Uint8Array;
  32672. /**
  32673. * Gets the current frequency data as a float array
  32674. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32675. * @returns a Float32Array
  32676. */
  32677. getFloatFrequencyData(): Float32Array;
  32678. /**
  32679. * Renders the debug canvas
  32680. */
  32681. drawDebugCanvas(): void;
  32682. /**
  32683. * Stops rendering the debug canvas and removes it
  32684. */
  32685. stopDebugCanvas(): void;
  32686. /**
  32687. * Connects two audio nodes
  32688. * @param inputAudioNode defines first node to connect
  32689. * @param outputAudioNode defines second node to connect
  32690. */
  32691. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32692. /**
  32693. * Releases all associated resources
  32694. */
  32695. dispose(): void;
  32696. }
  32697. }
  32698. declare module BABYLON {
  32699. /**
  32700. * This represents an audio engine and it is responsible
  32701. * to play, synchronize and analyse sounds throughout the application.
  32702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32703. */
  32704. export interface IAudioEngine extends IDisposable {
  32705. /**
  32706. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32707. */
  32708. readonly canUseWebAudio: boolean;
  32709. /**
  32710. * Gets the current AudioContext if available.
  32711. */
  32712. readonly audioContext: Nullable<AudioContext>;
  32713. /**
  32714. * The master gain node defines the global audio volume of your audio engine.
  32715. */
  32716. readonly masterGain: GainNode;
  32717. /**
  32718. * Gets whether or not mp3 are supported by your browser.
  32719. */
  32720. readonly isMP3supported: boolean;
  32721. /**
  32722. * Gets whether or not ogg are supported by your browser.
  32723. */
  32724. readonly isOGGsupported: boolean;
  32725. /**
  32726. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32727. * @ignoreNaming
  32728. */
  32729. WarnedWebAudioUnsupported: boolean;
  32730. /**
  32731. * Defines if the audio engine relies on a custom unlocked button.
  32732. * In this case, the embedded button will not be displayed.
  32733. */
  32734. useCustomUnlockedButton: boolean;
  32735. /**
  32736. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32737. */
  32738. readonly unlocked: boolean;
  32739. /**
  32740. * Event raised when audio has been unlocked on the browser.
  32741. */
  32742. onAudioUnlockedObservable: Observable<AudioEngine>;
  32743. /**
  32744. * Event raised when audio has been locked on the browser.
  32745. */
  32746. onAudioLockedObservable: Observable<AudioEngine>;
  32747. /**
  32748. * Flags the audio engine in Locked state.
  32749. * This happens due to new browser policies preventing audio to autoplay.
  32750. */
  32751. lock(): void;
  32752. /**
  32753. * Unlocks the audio engine once a user action has been done on the dom.
  32754. * This is helpful to resume play once browser policies have been satisfied.
  32755. */
  32756. unlock(): void;
  32757. /**
  32758. * Gets the global volume sets on the master gain.
  32759. * @returns the global volume if set or -1 otherwise
  32760. */
  32761. getGlobalVolume(): number;
  32762. /**
  32763. * Sets the global volume of your experience (sets on the master gain).
  32764. * @param newVolume Defines the new global volume of the application
  32765. */
  32766. setGlobalVolume(newVolume: number): void;
  32767. /**
  32768. * Connect the audio engine to an audio analyser allowing some amazing
  32769. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32771. * @param analyser The analyser to connect to the engine
  32772. */
  32773. connectToAnalyser(analyser: Analyser): void;
  32774. }
  32775. /**
  32776. * This represents the default audio engine used in babylon.
  32777. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32779. */
  32780. export class AudioEngine implements IAudioEngine {
  32781. private _audioContext;
  32782. private _audioContextInitialized;
  32783. private _muteButton;
  32784. private _hostElement;
  32785. /**
  32786. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32787. */
  32788. canUseWebAudio: boolean;
  32789. /**
  32790. * The master gain node defines the global audio volume of your audio engine.
  32791. */
  32792. masterGain: GainNode;
  32793. /**
  32794. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32795. * @ignoreNaming
  32796. */
  32797. WarnedWebAudioUnsupported: boolean;
  32798. /**
  32799. * Gets whether or not mp3 are supported by your browser.
  32800. */
  32801. isMP3supported: boolean;
  32802. /**
  32803. * Gets whether or not ogg are supported by your browser.
  32804. */
  32805. isOGGsupported: boolean;
  32806. /**
  32807. * Gets whether audio has been unlocked on the device.
  32808. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32809. * a user interaction has happened.
  32810. */
  32811. unlocked: boolean;
  32812. /**
  32813. * Defines if the audio engine relies on a custom unlocked button.
  32814. * In this case, the embedded button will not be displayed.
  32815. */
  32816. useCustomUnlockedButton: boolean;
  32817. /**
  32818. * Event raised when audio has been unlocked on the browser.
  32819. */
  32820. onAudioUnlockedObservable: Observable<AudioEngine>;
  32821. /**
  32822. * Event raised when audio has been locked on the browser.
  32823. */
  32824. onAudioLockedObservable: Observable<AudioEngine>;
  32825. /**
  32826. * Gets the current AudioContext if available.
  32827. */
  32828. get audioContext(): Nullable<AudioContext>;
  32829. private _connectedAnalyser;
  32830. /**
  32831. * Instantiates a new audio engine.
  32832. *
  32833. * There should be only one per page as some browsers restrict the number
  32834. * of audio contexts you can create.
  32835. * @param hostElement defines the host element where to display the mute icon if necessary
  32836. */
  32837. constructor(hostElement?: Nullable<HTMLElement>);
  32838. /**
  32839. * Flags the audio engine in Locked state.
  32840. * This happens due to new browser policies preventing audio to autoplay.
  32841. */
  32842. lock(): void;
  32843. /**
  32844. * Unlocks the audio engine once a user action has been done on the dom.
  32845. * This is helpful to resume play once browser policies have been satisfied.
  32846. */
  32847. unlock(): void;
  32848. private _resumeAudioContext;
  32849. private _initializeAudioContext;
  32850. private _tryToRun;
  32851. private _triggerRunningState;
  32852. private _triggerSuspendedState;
  32853. private _displayMuteButton;
  32854. private _moveButtonToTopLeft;
  32855. private _onResize;
  32856. private _hideMuteButton;
  32857. /**
  32858. * Destroy and release the resources associated with the audio ccontext.
  32859. */
  32860. dispose(): void;
  32861. /**
  32862. * Gets the global volume sets on the master gain.
  32863. * @returns the global volume if set or -1 otherwise
  32864. */
  32865. getGlobalVolume(): number;
  32866. /**
  32867. * Sets the global volume of your experience (sets on the master gain).
  32868. * @param newVolume Defines the new global volume of the application
  32869. */
  32870. setGlobalVolume(newVolume: number): void;
  32871. /**
  32872. * Connect the audio engine to an audio analyser allowing some amazing
  32873. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32875. * @param analyser The analyser to connect to the engine
  32876. */
  32877. connectToAnalyser(analyser: Analyser): void;
  32878. }
  32879. }
  32880. declare module BABYLON {
  32881. /**
  32882. * Interface used to present a loading screen while loading a scene
  32883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32884. */
  32885. export interface ILoadingScreen {
  32886. /**
  32887. * Function called to display the loading screen
  32888. */
  32889. displayLoadingUI: () => void;
  32890. /**
  32891. * Function called to hide the loading screen
  32892. */
  32893. hideLoadingUI: () => void;
  32894. /**
  32895. * Gets or sets the color to use for the background
  32896. */
  32897. loadingUIBackgroundColor: string;
  32898. /**
  32899. * Gets or sets the text to display while loading
  32900. */
  32901. loadingUIText: string;
  32902. }
  32903. /**
  32904. * Class used for the default loading screen
  32905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32906. */
  32907. export class DefaultLoadingScreen implements ILoadingScreen {
  32908. private _renderingCanvas;
  32909. private _loadingText;
  32910. private _loadingDivBackgroundColor;
  32911. private _loadingDiv;
  32912. private _loadingTextDiv;
  32913. /** Gets or sets the logo url to use for the default loading screen */
  32914. static DefaultLogoUrl: string;
  32915. /** Gets or sets the spinner url to use for the default loading screen */
  32916. static DefaultSpinnerUrl: string;
  32917. /**
  32918. * Creates a new default loading screen
  32919. * @param _renderingCanvas defines the canvas used to render the scene
  32920. * @param _loadingText defines the default text to display
  32921. * @param _loadingDivBackgroundColor defines the default background color
  32922. */
  32923. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32924. /**
  32925. * Function called to display the loading screen
  32926. */
  32927. displayLoadingUI(): void;
  32928. /**
  32929. * Function called to hide the loading screen
  32930. */
  32931. hideLoadingUI(): void;
  32932. /**
  32933. * Gets or sets the text to display while loading
  32934. */
  32935. set loadingUIText(text: string);
  32936. get loadingUIText(): string;
  32937. /**
  32938. * Gets or sets the color to use for the background
  32939. */
  32940. get loadingUIBackgroundColor(): string;
  32941. set loadingUIBackgroundColor(color: string);
  32942. private _resizeLoadingUI;
  32943. }
  32944. }
  32945. declare module BABYLON {
  32946. /**
  32947. * Interface for any object that can request an animation frame
  32948. */
  32949. export interface ICustomAnimationFrameRequester {
  32950. /**
  32951. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32952. */
  32953. renderFunction?: Function;
  32954. /**
  32955. * Called to request the next frame to render to
  32956. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32957. */
  32958. requestAnimationFrame: Function;
  32959. /**
  32960. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32961. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32962. */
  32963. requestID?: number;
  32964. }
  32965. }
  32966. declare module BABYLON {
  32967. /**
  32968. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32969. */
  32970. export class PerformanceMonitor {
  32971. private _enabled;
  32972. private _rollingFrameTime;
  32973. private _lastFrameTimeMs;
  32974. /**
  32975. * constructor
  32976. * @param frameSampleSize The number of samples required to saturate the sliding window
  32977. */
  32978. constructor(frameSampleSize?: number);
  32979. /**
  32980. * Samples current frame
  32981. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32982. */
  32983. sampleFrame(timeMs?: number): void;
  32984. /**
  32985. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32986. */
  32987. get averageFrameTime(): number;
  32988. /**
  32989. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32990. */
  32991. get averageFrameTimeVariance(): number;
  32992. /**
  32993. * Returns the frame time of the most recent frame
  32994. */
  32995. get instantaneousFrameTime(): number;
  32996. /**
  32997. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32998. */
  32999. get averageFPS(): number;
  33000. /**
  33001. * Returns the average framerate in frames per second using the most recent frame time
  33002. */
  33003. get instantaneousFPS(): number;
  33004. /**
  33005. * Returns true if enough samples have been taken to completely fill the sliding window
  33006. */
  33007. get isSaturated(): boolean;
  33008. /**
  33009. * Enables contributions to the sliding window sample set
  33010. */
  33011. enable(): void;
  33012. /**
  33013. * Disables contributions to the sliding window sample set
  33014. * Samples will not be interpolated over the disabled period
  33015. */
  33016. disable(): void;
  33017. /**
  33018. * Returns true if sampling is enabled
  33019. */
  33020. get isEnabled(): boolean;
  33021. /**
  33022. * Resets performance monitor
  33023. */
  33024. reset(): void;
  33025. }
  33026. /**
  33027. * RollingAverage
  33028. *
  33029. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33030. */
  33031. export class RollingAverage {
  33032. /**
  33033. * Current average
  33034. */
  33035. average: number;
  33036. /**
  33037. * Current variance
  33038. */
  33039. variance: number;
  33040. protected _samples: Array<number>;
  33041. protected _sampleCount: number;
  33042. protected _pos: number;
  33043. protected _m2: number;
  33044. /**
  33045. * constructor
  33046. * @param length The number of samples required to saturate the sliding window
  33047. */
  33048. constructor(length: number);
  33049. /**
  33050. * Adds a sample to the sample set
  33051. * @param v The sample value
  33052. */
  33053. add(v: number): void;
  33054. /**
  33055. * Returns previously added values or null if outside of history or outside the sliding window domain
  33056. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33057. * @return Value previously recorded with add() or null if outside of range
  33058. */
  33059. history(i: number): number;
  33060. /**
  33061. * Returns true if enough samples have been taken to completely fill the sliding window
  33062. * @return true if sample-set saturated
  33063. */
  33064. isSaturated(): boolean;
  33065. /**
  33066. * Resets the rolling average (equivalent to 0 samples taken so far)
  33067. */
  33068. reset(): void;
  33069. /**
  33070. * Wraps a value around the sample range boundaries
  33071. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33072. * @return Wrapped position in sample range
  33073. */
  33074. protected _wrapPosition(i: number): number;
  33075. }
  33076. }
  33077. declare module BABYLON {
  33078. /**
  33079. * This class is used to track a performance counter which is number based.
  33080. * The user has access to many properties which give statistics of different nature.
  33081. *
  33082. * The implementer can track two kinds of Performance Counter: time and count.
  33083. * 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.
  33084. * 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.
  33085. */
  33086. export class PerfCounter {
  33087. /**
  33088. * Gets or sets a global boolean to turn on and off all the counters
  33089. */
  33090. static Enabled: boolean;
  33091. /**
  33092. * Returns the smallest value ever
  33093. */
  33094. get min(): number;
  33095. /**
  33096. * Returns the biggest value ever
  33097. */
  33098. get max(): number;
  33099. /**
  33100. * Returns the average value since the performance counter is running
  33101. */
  33102. get average(): number;
  33103. /**
  33104. * Returns the average value of the last second the counter was monitored
  33105. */
  33106. get lastSecAverage(): number;
  33107. /**
  33108. * Returns the current value
  33109. */
  33110. get current(): number;
  33111. /**
  33112. * Gets the accumulated total
  33113. */
  33114. get total(): number;
  33115. /**
  33116. * Gets the total value count
  33117. */
  33118. get count(): number;
  33119. /**
  33120. * Creates a new counter
  33121. */
  33122. constructor();
  33123. /**
  33124. * Call this method to start monitoring a new frame.
  33125. * 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.
  33126. */
  33127. fetchNewFrame(): void;
  33128. /**
  33129. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33130. * @param newCount the count value to add to the monitored count
  33131. * @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.
  33132. */
  33133. addCount(newCount: number, fetchResult: boolean): void;
  33134. /**
  33135. * Start monitoring this performance counter
  33136. */
  33137. beginMonitoring(): void;
  33138. /**
  33139. * Compute the time lapsed since the previous beginMonitoring() call.
  33140. * @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
  33141. */
  33142. endMonitoring(newFrame?: boolean): void;
  33143. private _fetchResult;
  33144. private _startMonitoringTime;
  33145. private _min;
  33146. private _max;
  33147. private _average;
  33148. private _current;
  33149. private _totalValueCount;
  33150. private _totalAccumulated;
  33151. private _lastSecAverage;
  33152. private _lastSecAccumulated;
  33153. private _lastSecTime;
  33154. private _lastSecValueCount;
  33155. }
  33156. }
  33157. declare module BABYLON {
  33158. interface ThinEngine {
  33159. /**
  33160. * Sets alpha constants used by some alpha blending modes
  33161. * @param r defines the red component
  33162. * @param g defines the green component
  33163. * @param b defines the blue component
  33164. * @param a defines the alpha component
  33165. */
  33166. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33167. /**
  33168. * Sets the current alpha mode
  33169. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33170. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33171. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33172. */
  33173. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33174. /**
  33175. * Gets the current alpha mode
  33176. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33177. * @returns the current alpha mode
  33178. */
  33179. getAlphaMode(): number;
  33180. /**
  33181. * Sets the current alpha equation
  33182. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33183. */
  33184. setAlphaEquation(equation: number): void;
  33185. /**
  33186. * Gets the current alpha equation.
  33187. * @returns the current alpha equation
  33188. */
  33189. getAlphaEquation(): number;
  33190. }
  33191. }
  33192. declare module BABYLON {
  33193. /**
  33194. * Defines the interface used by display changed events
  33195. */
  33196. export interface IDisplayChangedEventArgs {
  33197. /** Gets the vrDisplay object (if any) */
  33198. vrDisplay: Nullable<any>;
  33199. /** Gets a boolean indicating if webVR is supported */
  33200. vrSupported: boolean;
  33201. }
  33202. /**
  33203. * Defines the interface used by objects containing a viewport (like a camera)
  33204. */
  33205. interface IViewportOwnerLike {
  33206. /**
  33207. * Gets or sets the viewport
  33208. */
  33209. viewport: IViewportLike;
  33210. }
  33211. /**
  33212. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33213. */
  33214. export class Engine extends ThinEngine {
  33215. /** Defines that alpha blending is disabled */
  33216. static readonly ALPHA_DISABLE: number;
  33217. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33218. static readonly ALPHA_ADD: number;
  33219. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33220. static readonly ALPHA_COMBINE: number;
  33221. /** Defines that alpha blending to DEST - SRC * DEST */
  33222. static readonly ALPHA_SUBTRACT: number;
  33223. /** Defines that alpha blending to SRC * DEST */
  33224. static readonly ALPHA_MULTIPLY: number;
  33225. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33226. static readonly ALPHA_MAXIMIZED: number;
  33227. /** Defines that alpha blending to SRC + DEST */
  33228. static readonly ALPHA_ONEONE: number;
  33229. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33230. static readonly ALPHA_PREMULTIPLIED: number;
  33231. /**
  33232. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33233. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33234. */
  33235. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33236. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33237. static readonly ALPHA_INTERPOLATE: number;
  33238. /**
  33239. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33240. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33241. */
  33242. static readonly ALPHA_SCREENMODE: number;
  33243. /** Defines that the ressource is not delayed*/
  33244. static readonly DELAYLOADSTATE_NONE: number;
  33245. /** Defines that the ressource was successfully delay loaded */
  33246. static readonly DELAYLOADSTATE_LOADED: number;
  33247. /** Defines that the ressource is currently delay loading */
  33248. static readonly DELAYLOADSTATE_LOADING: number;
  33249. /** Defines that the ressource is delayed and has not started loading */
  33250. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33251. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33252. static readonly NEVER: number;
  33253. /** 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 */
  33254. static readonly ALWAYS: number;
  33255. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33256. static readonly LESS: number;
  33257. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33258. static readonly EQUAL: number;
  33259. /** 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 */
  33260. static readonly LEQUAL: number;
  33261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33262. static readonly GREATER: number;
  33263. /** 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 */
  33264. static readonly GEQUAL: number;
  33265. /** 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 */
  33266. static readonly NOTEQUAL: number;
  33267. /** Passed to stencilOperation to specify that stencil value must be kept */
  33268. static readonly KEEP: number;
  33269. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33270. static readonly REPLACE: number;
  33271. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33272. static readonly INCR: number;
  33273. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33274. static readonly DECR: number;
  33275. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33276. static readonly INVERT: number;
  33277. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33278. static readonly INCR_WRAP: number;
  33279. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33280. static readonly DECR_WRAP: number;
  33281. /** Texture is not repeating outside of 0..1 UVs */
  33282. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33283. /** Texture is repeating outside of 0..1 UVs */
  33284. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33285. /** Texture is repeating and mirrored */
  33286. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33287. /** ALPHA */
  33288. static readonly TEXTUREFORMAT_ALPHA: number;
  33289. /** LUMINANCE */
  33290. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33291. /** LUMINANCE_ALPHA */
  33292. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33293. /** RGB */
  33294. static readonly TEXTUREFORMAT_RGB: number;
  33295. /** RGBA */
  33296. static readonly TEXTUREFORMAT_RGBA: number;
  33297. /** RED */
  33298. static readonly TEXTUREFORMAT_RED: number;
  33299. /** RED (2nd reference) */
  33300. static readonly TEXTUREFORMAT_R: number;
  33301. /** RG */
  33302. static readonly TEXTUREFORMAT_RG: number;
  33303. /** RED_INTEGER */
  33304. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33305. /** RED_INTEGER (2nd reference) */
  33306. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33307. /** RG_INTEGER */
  33308. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33309. /** RGB_INTEGER */
  33310. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33311. /** RGBA_INTEGER */
  33312. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33313. /** UNSIGNED_BYTE */
  33314. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33315. /** UNSIGNED_BYTE (2nd reference) */
  33316. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33317. /** FLOAT */
  33318. static readonly TEXTURETYPE_FLOAT: number;
  33319. /** HALF_FLOAT */
  33320. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33321. /** BYTE */
  33322. static readonly TEXTURETYPE_BYTE: number;
  33323. /** SHORT */
  33324. static readonly TEXTURETYPE_SHORT: number;
  33325. /** UNSIGNED_SHORT */
  33326. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33327. /** INT */
  33328. static readonly TEXTURETYPE_INT: number;
  33329. /** UNSIGNED_INT */
  33330. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33331. /** UNSIGNED_SHORT_4_4_4_4 */
  33332. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33333. /** UNSIGNED_SHORT_5_5_5_1 */
  33334. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33335. /** UNSIGNED_SHORT_5_6_5 */
  33336. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33337. /** UNSIGNED_INT_2_10_10_10_REV */
  33338. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33339. /** UNSIGNED_INT_24_8 */
  33340. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33341. /** UNSIGNED_INT_10F_11F_11F_REV */
  33342. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33343. /** UNSIGNED_INT_5_9_9_9_REV */
  33344. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33345. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33346. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33347. /** nearest is mag = nearest and min = nearest and mip = linear */
  33348. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33349. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33350. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33351. /** Trilinear is mag = linear and min = linear and mip = linear */
  33352. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33353. /** nearest is mag = nearest and min = nearest and mip = linear */
  33354. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33355. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33356. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33357. /** Trilinear is mag = linear and min = linear and mip = linear */
  33358. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33359. /** mag = nearest and min = nearest and mip = nearest */
  33360. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33361. /** mag = nearest and min = linear and mip = nearest */
  33362. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33363. /** mag = nearest and min = linear and mip = linear */
  33364. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33365. /** mag = nearest and min = linear and mip = none */
  33366. static readonly TEXTURE_NEAREST_LINEAR: number;
  33367. /** mag = nearest and min = nearest and mip = none */
  33368. static readonly TEXTURE_NEAREST_NEAREST: number;
  33369. /** mag = linear and min = nearest and mip = nearest */
  33370. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33371. /** mag = linear and min = nearest and mip = linear */
  33372. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33373. /** mag = linear and min = linear and mip = none */
  33374. static readonly TEXTURE_LINEAR_LINEAR: number;
  33375. /** mag = linear and min = nearest and mip = none */
  33376. static readonly TEXTURE_LINEAR_NEAREST: number;
  33377. /** Explicit coordinates mode */
  33378. static readonly TEXTURE_EXPLICIT_MODE: number;
  33379. /** Spherical coordinates mode */
  33380. static readonly TEXTURE_SPHERICAL_MODE: number;
  33381. /** Planar coordinates mode */
  33382. static readonly TEXTURE_PLANAR_MODE: number;
  33383. /** Cubic coordinates mode */
  33384. static readonly TEXTURE_CUBIC_MODE: number;
  33385. /** Projection coordinates mode */
  33386. static readonly TEXTURE_PROJECTION_MODE: number;
  33387. /** Skybox coordinates mode */
  33388. static readonly TEXTURE_SKYBOX_MODE: number;
  33389. /** Inverse Cubic coordinates mode */
  33390. static readonly TEXTURE_INVCUBIC_MODE: number;
  33391. /** Equirectangular coordinates mode */
  33392. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33393. /** Equirectangular Fixed coordinates mode */
  33394. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33395. /** Equirectangular Fixed Mirrored coordinates mode */
  33396. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33397. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33398. static readonly SCALEMODE_FLOOR: number;
  33399. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33400. static readonly SCALEMODE_NEAREST: number;
  33401. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33402. static readonly SCALEMODE_CEILING: number;
  33403. /**
  33404. * Returns the current npm package of the sdk
  33405. */
  33406. static get NpmPackage(): string;
  33407. /**
  33408. * Returns the current version of the framework
  33409. */
  33410. static get Version(): string;
  33411. /** Gets the list of created engines */
  33412. static get Instances(): Engine[];
  33413. /**
  33414. * Gets the latest created engine
  33415. */
  33416. static get LastCreatedEngine(): Nullable<Engine>;
  33417. /**
  33418. * Gets the latest created scene
  33419. */
  33420. static get LastCreatedScene(): Nullable<Scene>;
  33421. /**
  33422. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33423. * @param flag defines which part of the materials must be marked as dirty
  33424. * @param predicate defines a predicate used to filter which materials should be affected
  33425. */
  33426. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33427. /**
  33428. * Method called to create the default loading screen.
  33429. * This can be overriden in your own app.
  33430. * @param canvas The rendering canvas element
  33431. * @returns The loading screen
  33432. */
  33433. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33434. /**
  33435. * Method called to create the default rescale post process on each engine.
  33436. */
  33437. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33438. /**
  33439. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33440. **/
  33441. enableOfflineSupport: boolean;
  33442. /**
  33443. * 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)
  33444. **/
  33445. disableManifestCheck: boolean;
  33446. /**
  33447. * Gets the list of created scenes
  33448. */
  33449. scenes: Scene[];
  33450. /**
  33451. * Event raised when a new scene is created
  33452. */
  33453. onNewSceneAddedObservable: Observable<Scene>;
  33454. /**
  33455. * Gets the list of created postprocesses
  33456. */
  33457. postProcesses: PostProcess[];
  33458. /**
  33459. * Gets a boolean indicating if the pointer is currently locked
  33460. */
  33461. isPointerLock: boolean;
  33462. /**
  33463. * Observable event triggered each time the rendering canvas is resized
  33464. */
  33465. onResizeObservable: Observable<Engine>;
  33466. /**
  33467. * Observable event triggered each time the canvas loses focus
  33468. */
  33469. onCanvasBlurObservable: Observable<Engine>;
  33470. /**
  33471. * Observable event triggered each time the canvas gains focus
  33472. */
  33473. onCanvasFocusObservable: Observable<Engine>;
  33474. /**
  33475. * Observable event triggered each time the canvas receives pointerout event
  33476. */
  33477. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33478. /**
  33479. * Observable raised when the engine begins a new frame
  33480. */
  33481. onBeginFrameObservable: Observable<Engine>;
  33482. /**
  33483. * If set, will be used to request the next animation frame for the render loop
  33484. */
  33485. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33486. /**
  33487. * Observable raised when the engine ends the current frame
  33488. */
  33489. onEndFrameObservable: Observable<Engine>;
  33490. /**
  33491. * Observable raised when the engine is about to compile a shader
  33492. */
  33493. onBeforeShaderCompilationObservable: Observable<Engine>;
  33494. /**
  33495. * Observable raised when the engine has jsut compiled a shader
  33496. */
  33497. onAfterShaderCompilationObservable: Observable<Engine>;
  33498. /**
  33499. * Gets the audio engine
  33500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33501. * @ignorenaming
  33502. */
  33503. static audioEngine: IAudioEngine;
  33504. /**
  33505. * Default AudioEngine factory responsible of creating the Audio Engine.
  33506. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33507. */
  33508. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33509. /**
  33510. * Default offline support factory responsible of creating a tool used to store data locally.
  33511. * By default, this will create a Database object if the workload has been embedded.
  33512. */
  33513. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33514. private _loadingScreen;
  33515. private _pointerLockRequested;
  33516. private _dummyFramebuffer;
  33517. private _rescalePostProcess;
  33518. private _deterministicLockstep;
  33519. private _lockstepMaxSteps;
  33520. private _timeStep;
  33521. protected get _supportsHardwareTextureRescaling(): boolean;
  33522. private _fps;
  33523. private _deltaTime;
  33524. /** @hidden */
  33525. _drawCalls: PerfCounter;
  33526. /** 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 */
  33527. canvasTabIndex: number;
  33528. /**
  33529. * Turn this value on if you want to pause FPS computation when in background
  33530. */
  33531. disablePerformanceMonitorInBackground: boolean;
  33532. private _performanceMonitor;
  33533. /**
  33534. * Gets the performance monitor attached to this engine
  33535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33536. */
  33537. get performanceMonitor(): PerformanceMonitor;
  33538. private _onFocus;
  33539. private _onBlur;
  33540. private _onCanvasPointerOut;
  33541. private _onCanvasBlur;
  33542. private _onCanvasFocus;
  33543. private _onFullscreenChange;
  33544. private _onPointerLockChange;
  33545. /**
  33546. * Gets the HTML element used to attach event listeners
  33547. * @returns a HTML element
  33548. */
  33549. getInputElement(): Nullable<HTMLElement>;
  33550. /**
  33551. * Creates a new engine
  33552. * @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
  33553. * @param antialias defines enable antialiasing (default: false)
  33554. * @param options defines further options to be sent to the getContext() function
  33555. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33556. */
  33557. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33558. /**
  33559. * Gets current aspect ratio
  33560. * @param viewportOwner defines the camera to use to get the aspect ratio
  33561. * @param useScreen defines if screen size must be used (or the current render target if any)
  33562. * @returns a number defining the aspect ratio
  33563. */
  33564. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33565. /**
  33566. * Gets current screen aspect ratio
  33567. * @returns a number defining the aspect ratio
  33568. */
  33569. getScreenAspectRatio(): number;
  33570. /**
  33571. * Gets the client rect of the HTML canvas attached with the current webGL context
  33572. * @returns a client rectanglee
  33573. */
  33574. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33575. /**
  33576. * Gets the client rect of the HTML element used for events
  33577. * @returns a client rectanglee
  33578. */
  33579. getInputElementClientRect(): Nullable<ClientRect>;
  33580. /**
  33581. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33583. * @returns true if engine is in deterministic lock step mode
  33584. */
  33585. isDeterministicLockStep(): boolean;
  33586. /**
  33587. * Gets the max steps when engine is running in deterministic lock step
  33588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33589. * @returns the max steps
  33590. */
  33591. getLockstepMaxSteps(): number;
  33592. /**
  33593. * Returns the time in ms between steps when using deterministic lock step.
  33594. * @returns time step in (ms)
  33595. */
  33596. getTimeStep(): number;
  33597. /**
  33598. * Force the mipmap generation for the given render target texture
  33599. * @param texture defines the render target texture to use
  33600. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33601. */
  33602. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33603. /** States */
  33604. /**
  33605. * Set various states to the webGL context
  33606. * @param culling defines backface culling state
  33607. * @param zOffset defines the value to apply to zOffset (0 by default)
  33608. * @param force defines if states must be applied even if cache is up to date
  33609. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33610. */
  33611. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33612. /**
  33613. * Set the z offset to apply to current rendering
  33614. * @param value defines the offset to apply
  33615. */
  33616. setZOffset(value: number): void;
  33617. /**
  33618. * Gets the current value of the zOffset
  33619. * @returns the current zOffset state
  33620. */
  33621. getZOffset(): number;
  33622. /**
  33623. * Enable or disable depth buffering
  33624. * @param enable defines the state to set
  33625. */
  33626. setDepthBuffer(enable: boolean): void;
  33627. /**
  33628. * Gets a boolean indicating if depth writing is enabled
  33629. * @returns the current depth writing state
  33630. */
  33631. getDepthWrite(): boolean;
  33632. /**
  33633. * Enable or disable depth writing
  33634. * @param enable defines the state to set
  33635. */
  33636. setDepthWrite(enable: boolean): void;
  33637. /**
  33638. * Gets a boolean indicating if stencil buffer is enabled
  33639. * @returns the current stencil buffer state
  33640. */
  33641. getStencilBuffer(): boolean;
  33642. /**
  33643. * Enable or disable the stencil buffer
  33644. * @param enable defines if the stencil buffer must be enabled or disabled
  33645. */
  33646. setStencilBuffer(enable: boolean): void;
  33647. /**
  33648. * Gets the current stencil mask
  33649. * @returns a number defining the new stencil mask to use
  33650. */
  33651. getStencilMask(): number;
  33652. /**
  33653. * Sets the current stencil mask
  33654. * @param mask defines the new stencil mask to use
  33655. */
  33656. setStencilMask(mask: number): void;
  33657. /**
  33658. * Gets the current stencil function
  33659. * @returns a number defining the stencil function to use
  33660. */
  33661. getStencilFunction(): number;
  33662. /**
  33663. * Gets the current stencil reference value
  33664. * @returns a number defining the stencil reference value to use
  33665. */
  33666. getStencilFunctionReference(): number;
  33667. /**
  33668. * Gets the current stencil mask
  33669. * @returns a number defining the stencil mask to use
  33670. */
  33671. getStencilFunctionMask(): number;
  33672. /**
  33673. * Sets the current stencil function
  33674. * @param stencilFunc defines the new stencil function to use
  33675. */
  33676. setStencilFunction(stencilFunc: number): void;
  33677. /**
  33678. * Sets the current stencil reference
  33679. * @param reference defines the new stencil reference to use
  33680. */
  33681. setStencilFunctionReference(reference: number): void;
  33682. /**
  33683. * Sets the current stencil mask
  33684. * @param mask defines the new stencil mask to use
  33685. */
  33686. setStencilFunctionMask(mask: number): void;
  33687. /**
  33688. * Gets the current stencil operation when stencil fails
  33689. * @returns a number defining stencil operation to use when stencil fails
  33690. */
  33691. getStencilOperationFail(): number;
  33692. /**
  33693. * Gets the current stencil operation when depth fails
  33694. * @returns a number defining stencil operation to use when depth fails
  33695. */
  33696. getStencilOperationDepthFail(): number;
  33697. /**
  33698. * Gets the current stencil operation when stencil passes
  33699. * @returns a number defining stencil operation to use when stencil passes
  33700. */
  33701. getStencilOperationPass(): number;
  33702. /**
  33703. * Sets the stencil operation to use when stencil fails
  33704. * @param operation defines the stencil operation to use when stencil fails
  33705. */
  33706. setStencilOperationFail(operation: number): void;
  33707. /**
  33708. * Sets the stencil operation to use when depth fails
  33709. * @param operation defines the stencil operation to use when depth fails
  33710. */
  33711. setStencilOperationDepthFail(operation: number): void;
  33712. /**
  33713. * Sets the stencil operation to use when stencil passes
  33714. * @param operation defines the stencil operation to use when stencil passes
  33715. */
  33716. setStencilOperationPass(operation: number): void;
  33717. /**
  33718. * Sets a boolean indicating if the dithering state is enabled or disabled
  33719. * @param value defines the dithering state
  33720. */
  33721. setDitheringState(value: boolean): void;
  33722. /**
  33723. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33724. * @param value defines the rasterizer state
  33725. */
  33726. setRasterizerState(value: boolean): void;
  33727. /**
  33728. * Gets the current depth function
  33729. * @returns a number defining the depth function
  33730. */
  33731. getDepthFunction(): Nullable<number>;
  33732. /**
  33733. * Sets the current depth function
  33734. * @param depthFunc defines the function to use
  33735. */
  33736. setDepthFunction(depthFunc: number): void;
  33737. /**
  33738. * Sets the current depth function to GREATER
  33739. */
  33740. setDepthFunctionToGreater(): void;
  33741. /**
  33742. * Sets the current depth function to GEQUAL
  33743. */
  33744. setDepthFunctionToGreaterOrEqual(): void;
  33745. /**
  33746. * Sets the current depth function to LESS
  33747. */
  33748. setDepthFunctionToLess(): void;
  33749. /**
  33750. * Sets the current depth function to LEQUAL
  33751. */
  33752. setDepthFunctionToLessOrEqual(): void;
  33753. private _cachedStencilBuffer;
  33754. private _cachedStencilFunction;
  33755. private _cachedStencilMask;
  33756. private _cachedStencilOperationPass;
  33757. private _cachedStencilOperationFail;
  33758. private _cachedStencilOperationDepthFail;
  33759. private _cachedStencilReference;
  33760. /**
  33761. * Caches the the state of the stencil buffer
  33762. */
  33763. cacheStencilState(): void;
  33764. /**
  33765. * Restores the state of the stencil buffer
  33766. */
  33767. restoreStencilState(): void;
  33768. /**
  33769. * Directly set the WebGL Viewport
  33770. * @param x defines the x coordinate of the viewport (in screen space)
  33771. * @param y defines the y coordinate of the viewport (in screen space)
  33772. * @param width defines the width of the viewport (in screen space)
  33773. * @param height defines the height of the viewport (in screen space)
  33774. * @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
  33775. */
  33776. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33777. /**
  33778. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33779. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33780. * @param y defines the y-coordinate of the corner of the clear rectangle
  33781. * @param width defines the width of the clear rectangle
  33782. * @param height defines the height of the clear rectangle
  33783. * @param clearColor defines the clear color
  33784. */
  33785. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33786. /**
  33787. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33788. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33789. * @param y defines the y-coordinate of the corner of the clear rectangle
  33790. * @param width defines the width of the clear rectangle
  33791. * @param height defines the height of the clear rectangle
  33792. */
  33793. enableScissor(x: number, y: number, width: number, height: number): void;
  33794. /**
  33795. * Disable previously set scissor test rectangle
  33796. */
  33797. disableScissor(): void;
  33798. protected _reportDrawCall(): void;
  33799. /**
  33800. * Initializes a webVR display and starts listening to display change events
  33801. * The onVRDisplayChangedObservable will be notified upon these changes
  33802. * @returns The onVRDisplayChangedObservable
  33803. */
  33804. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33805. /** @hidden */
  33806. _prepareVRComponent(): void;
  33807. /** @hidden */
  33808. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33809. /** @hidden */
  33810. _submitVRFrame(): void;
  33811. /**
  33812. * Call this function to leave webVR mode
  33813. * Will do nothing if webVR is not supported or if there is no webVR device
  33814. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33815. */
  33816. disableVR(): void;
  33817. /**
  33818. * Gets a boolean indicating that the system is in VR mode and is presenting
  33819. * @returns true if VR mode is engaged
  33820. */
  33821. isVRPresenting(): boolean;
  33822. /** @hidden */
  33823. _requestVRFrame(): void;
  33824. /** @hidden */
  33825. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33826. /**
  33827. * Gets the source code of the vertex shader associated with a specific webGL program
  33828. * @param program defines the program to use
  33829. * @returns a string containing the source code of the vertex shader associated with the program
  33830. */
  33831. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33832. /**
  33833. * Gets the source code of the fragment shader associated with a specific webGL program
  33834. * @param program defines the program to use
  33835. * @returns a string containing the source code of the fragment shader associated with the program
  33836. */
  33837. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33838. /**
  33839. * Sets a depth stencil texture from a render target to the according uniform.
  33840. * @param channel The texture channel
  33841. * @param uniform The uniform to set
  33842. * @param texture The render target texture containing the depth stencil texture to apply
  33843. */
  33844. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33845. /**
  33846. * Sets a texture to the webGL context from a postprocess
  33847. * @param channel defines the channel to use
  33848. * @param postProcess defines the source postprocess
  33849. */
  33850. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33851. /**
  33852. * Binds the output of the passed in post process to the texture channel specified
  33853. * @param channel The channel the texture should be bound to
  33854. * @param postProcess The post process which's output should be bound
  33855. */
  33856. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33857. /** @hidden */
  33858. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33859. protected _rebuildBuffers(): void;
  33860. /** @hidden */
  33861. _renderFrame(): void;
  33862. _renderLoop(): void;
  33863. /** @hidden */
  33864. _renderViews(): boolean;
  33865. /**
  33866. * Toggle full screen mode
  33867. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33868. */
  33869. switchFullscreen(requestPointerLock: boolean): void;
  33870. /**
  33871. * Enters full screen mode
  33872. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33873. */
  33874. enterFullscreen(requestPointerLock: boolean): void;
  33875. /**
  33876. * Exits full screen mode
  33877. */
  33878. exitFullscreen(): void;
  33879. /**
  33880. * Enters Pointerlock mode
  33881. */
  33882. enterPointerlock(): void;
  33883. /**
  33884. * Exits Pointerlock mode
  33885. */
  33886. exitPointerlock(): void;
  33887. /**
  33888. * Begin a new frame
  33889. */
  33890. beginFrame(): void;
  33891. /**
  33892. * Enf the current frame
  33893. */
  33894. endFrame(): void;
  33895. resize(): void;
  33896. /**
  33897. * Force a specific size of the canvas
  33898. * @param width defines the new canvas' width
  33899. * @param height defines the new canvas' height
  33900. */
  33901. setSize(width: number, height: number): void;
  33902. /**
  33903. * Updates a dynamic vertex buffer.
  33904. * @param vertexBuffer the vertex buffer to update
  33905. * @param data the data used to update the vertex buffer
  33906. * @param byteOffset the byte offset of the data
  33907. * @param byteLength the byte length of the data
  33908. */
  33909. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33910. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33911. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33912. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33913. _releaseTexture(texture: InternalTexture): void;
  33914. /**
  33915. * @hidden
  33916. * Rescales a texture
  33917. * @param source input texutre
  33918. * @param destination destination texture
  33919. * @param scene scene to use to render the resize
  33920. * @param internalFormat format to use when resizing
  33921. * @param onComplete callback to be called when resize has completed
  33922. */
  33923. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33924. /**
  33925. * Gets the current framerate
  33926. * @returns a number representing the framerate
  33927. */
  33928. getFps(): number;
  33929. /**
  33930. * Gets the time spent between current and previous frame
  33931. * @returns a number representing the delta time in ms
  33932. */
  33933. getDeltaTime(): number;
  33934. private _measureFps;
  33935. /** @hidden */
  33936. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33937. /**
  33938. * Update a dynamic index buffer
  33939. * @param indexBuffer defines the target index buffer
  33940. * @param indices defines the data to update
  33941. * @param offset defines the offset in the target index buffer where update should start
  33942. */
  33943. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33944. /**
  33945. * Updates the sample count of a render target texture
  33946. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33947. * @param texture defines the texture to update
  33948. * @param samples defines the sample count to set
  33949. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33950. */
  33951. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33952. /**
  33953. * Updates a depth texture Comparison Mode and Function.
  33954. * If the comparison Function is equal to 0, the mode will be set to none.
  33955. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33956. * @param texture The texture to set the comparison function for
  33957. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33958. */
  33959. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33960. /**
  33961. * Creates a webGL buffer to use with instanciation
  33962. * @param capacity defines the size of the buffer
  33963. * @returns the webGL buffer
  33964. */
  33965. createInstancesBuffer(capacity: number): DataBuffer;
  33966. /**
  33967. * Delete a webGL buffer used with instanciation
  33968. * @param buffer defines the webGL buffer to delete
  33969. */
  33970. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33971. private _clientWaitAsync;
  33972. /** @hidden */
  33973. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33974. /** @hidden */
  33975. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33976. dispose(): void;
  33977. private _disableTouchAction;
  33978. /**
  33979. * Display the loading screen
  33980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33981. */
  33982. displayLoadingUI(): void;
  33983. /**
  33984. * Hide the loading screen
  33985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33986. */
  33987. hideLoadingUI(): void;
  33988. /**
  33989. * Gets the current loading screen object
  33990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33991. */
  33992. get loadingScreen(): ILoadingScreen;
  33993. /**
  33994. * Sets the current loading screen object
  33995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33996. */
  33997. set loadingScreen(loadingScreen: ILoadingScreen);
  33998. /**
  33999. * Sets the current loading screen text
  34000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34001. */
  34002. set loadingUIText(text: string);
  34003. /**
  34004. * Sets the current loading screen background color
  34005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34006. */
  34007. set loadingUIBackgroundColor(color: string);
  34008. /** Pointerlock and fullscreen */
  34009. /**
  34010. * Ask the browser to promote the current element to pointerlock mode
  34011. * @param element defines the DOM element to promote
  34012. */
  34013. static _RequestPointerlock(element: HTMLElement): void;
  34014. /**
  34015. * Asks the browser to exit pointerlock mode
  34016. */
  34017. static _ExitPointerlock(): void;
  34018. /**
  34019. * Ask the browser to promote the current element to fullscreen rendering mode
  34020. * @param element defines the DOM element to promote
  34021. */
  34022. static _RequestFullscreen(element: HTMLElement): void;
  34023. /**
  34024. * Asks the browser to exit fullscreen mode
  34025. */
  34026. static _ExitFullscreen(): void;
  34027. }
  34028. }
  34029. declare module BABYLON {
  34030. /**
  34031. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34032. * during the life time of the application.
  34033. */
  34034. export class EngineStore {
  34035. /** Gets the list of created engines */
  34036. static Instances: Engine[];
  34037. /** @hidden */
  34038. static _LastCreatedScene: Nullable<Scene>;
  34039. /**
  34040. * Gets the latest created engine
  34041. */
  34042. static get LastCreatedEngine(): Nullable<Engine>;
  34043. /**
  34044. * Gets the latest created scene
  34045. */
  34046. static get LastCreatedScene(): Nullable<Scene>;
  34047. /**
  34048. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34049. * @ignorenaming
  34050. */
  34051. static UseFallbackTexture: boolean;
  34052. /**
  34053. * Texture content used if a texture cannot loaded
  34054. * @ignorenaming
  34055. */
  34056. static FallbackTexture: string;
  34057. }
  34058. }
  34059. declare module BABYLON {
  34060. /**
  34061. * Helper class that provides a small promise polyfill
  34062. */
  34063. export class PromisePolyfill {
  34064. /**
  34065. * Static function used to check if the polyfill is required
  34066. * If this is the case then the function will inject the polyfill to window.Promise
  34067. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34068. */
  34069. static Apply(force?: boolean): void;
  34070. }
  34071. }
  34072. declare module BABYLON {
  34073. /**
  34074. * Interface for screenshot methods with describe argument called `size` as object with options
  34075. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34076. */
  34077. export interface IScreenshotSize {
  34078. /**
  34079. * number in pixels for canvas height
  34080. */
  34081. height?: number;
  34082. /**
  34083. * multiplier allowing render at a higher or lower resolution
  34084. * If value is defined then height and width will be ignored and taken from camera
  34085. */
  34086. precision?: number;
  34087. /**
  34088. * number in pixels for canvas width
  34089. */
  34090. width?: number;
  34091. }
  34092. }
  34093. declare module BABYLON {
  34094. interface IColor4Like {
  34095. r: float;
  34096. g: float;
  34097. b: float;
  34098. a: float;
  34099. }
  34100. /**
  34101. * Class containing a set of static utilities functions
  34102. */
  34103. export class Tools {
  34104. /**
  34105. * Gets or sets the base URL to use to load assets
  34106. */
  34107. static get BaseUrl(): string;
  34108. static set BaseUrl(value: string);
  34109. /**
  34110. * Enable/Disable Custom HTTP Request Headers globally.
  34111. * default = false
  34112. * @see CustomRequestHeaders
  34113. */
  34114. static UseCustomRequestHeaders: boolean;
  34115. /**
  34116. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34117. * i.e. when loading files, where the server/service expects an Authorization header
  34118. */
  34119. static CustomRequestHeaders: {
  34120. [key: string]: string;
  34121. };
  34122. /**
  34123. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34124. */
  34125. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34126. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34127. /**
  34128. * Default behaviour for cors in the application.
  34129. * It can be a string if the expected behavior is identical in the entire app.
  34130. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34131. */
  34132. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34133. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34134. /**
  34135. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34136. * @ignorenaming
  34137. */
  34138. static get UseFallbackTexture(): boolean;
  34139. static set UseFallbackTexture(value: boolean);
  34140. /**
  34141. * Use this object to register external classes like custom textures or material
  34142. * to allow the laoders to instantiate them
  34143. */
  34144. static get RegisteredExternalClasses(): {
  34145. [key: string]: Object;
  34146. };
  34147. static set RegisteredExternalClasses(classes: {
  34148. [key: string]: Object;
  34149. });
  34150. /**
  34151. * Texture content used if a texture cannot loaded
  34152. * @ignorenaming
  34153. */
  34154. static get fallbackTexture(): string;
  34155. static set fallbackTexture(value: string);
  34156. /**
  34157. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34158. * @param u defines the coordinate on X axis
  34159. * @param v defines the coordinate on Y axis
  34160. * @param width defines the width of the source data
  34161. * @param height defines the height of the source data
  34162. * @param pixels defines the source byte array
  34163. * @param color defines the output color
  34164. */
  34165. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34166. /**
  34167. * Interpolates between a and b via alpha
  34168. * @param a The lower value (returned when alpha = 0)
  34169. * @param b The upper value (returned when alpha = 1)
  34170. * @param alpha The interpolation-factor
  34171. * @return The mixed value
  34172. */
  34173. static Mix(a: number, b: number, alpha: number): number;
  34174. /**
  34175. * Tries to instantiate a new object from a given class name
  34176. * @param className defines the class name to instantiate
  34177. * @returns the new object or null if the system was not able to do the instantiation
  34178. */
  34179. static Instantiate(className: string): any;
  34180. /**
  34181. * Provides a slice function that will work even on IE
  34182. * @param data defines the array to slice
  34183. * @param start defines the start of the data (optional)
  34184. * @param end defines the end of the data (optional)
  34185. * @returns the new sliced array
  34186. */
  34187. static Slice<T>(data: T, start?: number, end?: number): T;
  34188. /**
  34189. * Polyfill for setImmediate
  34190. * @param action defines the action to execute after the current execution block
  34191. */
  34192. static SetImmediate(action: () => void): void;
  34193. /**
  34194. * Function indicating if a number is an exponent of 2
  34195. * @param value defines the value to test
  34196. * @returns true if the value is an exponent of 2
  34197. */
  34198. static IsExponentOfTwo(value: number): boolean;
  34199. private static _tmpFloatArray;
  34200. /**
  34201. * Returns the nearest 32-bit single precision float representation of a Number
  34202. * @param value A Number. If the parameter is of a different type, it will get converted
  34203. * to a number or to NaN if it cannot be converted
  34204. * @returns number
  34205. */
  34206. static FloatRound(value: number): number;
  34207. /**
  34208. * Extracts the filename from a path
  34209. * @param path defines the path to use
  34210. * @returns the filename
  34211. */
  34212. static GetFilename(path: string): string;
  34213. /**
  34214. * Extracts the "folder" part of a path (everything before the filename).
  34215. * @param uri The URI to extract the info from
  34216. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34217. * @returns The "folder" part of the path
  34218. */
  34219. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34220. /**
  34221. * Extracts text content from a DOM element hierarchy
  34222. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34223. */
  34224. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34225. /**
  34226. * Convert an angle in radians to degrees
  34227. * @param angle defines the angle to convert
  34228. * @returns the angle in degrees
  34229. */
  34230. static ToDegrees(angle: number): number;
  34231. /**
  34232. * Convert an angle in degrees to radians
  34233. * @param angle defines the angle to convert
  34234. * @returns the angle in radians
  34235. */
  34236. static ToRadians(angle: number): number;
  34237. /**
  34238. * Returns an array if obj is not an array
  34239. * @param obj defines the object to evaluate as an array
  34240. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34241. * @returns either obj directly if obj is an array or a new array containing obj
  34242. */
  34243. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34244. /**
  34245. * Gets the pointer prefix to use
  34246. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34247. */
  34248. static GetPointerPrefix(): string;
  34249. /**
  34250. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34251. * @param url define the url we are trying
  34252. * @param element define the dom element where to configure the cors policy
  34253. */
  34254. static SetCorsBehavior(url: string | string[], element: {
  34255. crossOrigin: string | null;
  34256. }): void;
  34257. /**
  34258. * Removes unwanted characters from an url
  34259. * @param url defines the url to clean
  34260. * @returns the cleaned url
  34261. */
  34262. static CleanUrl(url: string): string;
  34263. /**
  34264. * Gets or sets a function used to pre-process url before using them to load assets
  34265. */
  34266. static get PreprocessUrl(): (url: string) => string;
  34267. static set PreprocessUrl(processor: (url: string) => string);
  34268. /**
  34269. * Loads an image as an HTMLImageElement.
  34270. * @param input url string, ArrayBuffer, or Blob to load
  34271. * @param onLoad callback called when the image successfully loads
  34272. * @param onError callback called when the image fails to load
  34273. * @param offlineProvider offline provider for caching
  34274. * @param mimeType optional mime type
  34275. * @returns the HTMLImageElement of the loaded image
  34276. */
  34277. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34278. /**
  34279. * Loads a file from a url
  34280. * @param url url string, ArrayBuffer, or Blob to load
  34281. * @param onSuccess callback called when the file successfully loads
  34282. * @param onProgress callback called while file is loading (if the server supports this mode)
  34283. * @param offlineProvider defines the offline provider for caching
  34284. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34285. * @param onError callback called when the file fails to load
  34286. * @returns a file request object
  34287. */
  34288. 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;
  34289. /**
  34290. * Loads a file from a url
  34291. * @param url the file url to load
  34292. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34293. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34294. */
  34295. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34296. /**
  34297. * Load a script (identified by an url). When the url returns, the
  34298. * content of this file is added into a new script element, attached to the DOM (body element)
  34299. * @param scriptUrl defines the url of the script to laod
  34300. * @param onSuccess defines the callback called when the script is loaded
  34301. * @param onError defines the callback to call if an error occurs
  34302. * @param scriptId defines the id of the script element
  34303. */
  34304. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34305. /**
  34306. * Load an asynchronous script (identified by an url). When the url returns, the
  34307. * content of this file is added into a new script element, attached to the DOM (body element)
  34308. * @param scriptUrl defines the url of the script to laod
  34309. * @param scriptId defines the id of the script element
  34310. * @returns a promise request object
  34311. */
  34312. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34313. /**
  34314. * Loads a file from a blob
  34315. * @param fileToLoad defines the blob to use
  34316. * @param callback defines the callback to call when data is loaded
  34317. * @param progressCallback defines the callback to call during loading process
  34318. * @returns a file request object
  34319. */
  34320. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34321. /**
  34322. * Reads a file from a File object
  34323. * @param file defines the file to load
  34324. * @param onSuccess defines the callback to call when data is loaded
  34325. * @param onProgress defines the callback to call during loading process
  34326. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34327. * @param onError defines the callback to call when an error occurs
  34328. * @returns a file request object
  34329. */
  34330. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34331. /**
  34332. * Creates a data url from a given string content
  34333. * @param content defines the content to convert
  34334. * @returns the new data url link
  34335. */
  34336. static FileAsURL(content: string): string;
  34337. /**
  34338. * Format the given number to a specific decimal format
  34339. * @param value defines the number to format
  34340. * @param decimals defines the number of decimals to use
  34341. * @returns the formatted string
  34342. */
  34343. static Format(value: number, decimals?: number): string;
  34344. /**
  34345. * Tries to copy an object by duplicating every property
  34346. * @param source defines the source object
  34347. * @param destination defines the target object
  34348. * @param doNotCopyList defines a list of properties to avoid
  34349. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34350. */
  34351. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34352. /**
  34353. * Gets a boolean indicating if the given object has no own property
  34354. * @param obj defines the object to test
  34355. * @returns true if object has no own property
  34356. */
  34357. static IsEmpty(obj: any): boolean;
  34358. /**
  34359. * Function used to register events at window level
  34360. * @param windowElement defines the Window object to use
  34361. * @param events defines the events to register
  34362. */
  34363. static RegisterTopRootEvents(windowElement: Window, events: {
  34364. name: string;
  34365. handler: Nullable<(e: FocusEvent) => any>;
  34366. }[]): void;
  34367. /**
  34368. * Function used to unregister events from window level
  34369. * @param windowElement defines the Window object to use
  34370. * @param events defines the events to unregister
  34371. */
  34372. static UnregisterTopRootEvents(windowElement: Window, events: {
  34373. name: string;
  34374. handler: Nullable<(e: FocusEvent) => any>;
  34375. }[]): void;
  34376. /**
  34377. * @ignore
  34378. */
  34379. static _ScreenshotCanvas: HTMLCanvasElement;
  34380. /**
  34381. * Dumps the current bound framebuffer
  34382. * @param width defines the rendering width
  34383. * @param height defines the rendering height
  34384. * @param engine defines the hosting engine
  34385. * @param successCallback defines the callback triggered once the data are available
  34386. * @param mimeType defines the mime type of the result
  34387. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34388. */
  34389. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34390. /**
  34391. * Converts the canvas data to blob.
  34392. * This acts as a polyfill for browsers not supporting the to blob function.
  34393. * @param canvas Defines the canvas to extract the data from
  34394. * @param successCallback Defines the callback triggered once the data are available
  34395. * @param mimeType Defines the mime type of the result
  34396. */
  34397. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34398. /**
  34399. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34400. * @param successCallback defines the callback triggered once the data are available
  34401. * @param mimeType defines the mime type of the result
  34402. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34403. */
  34404. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34405. /**
  34406. * Downloads a blob in the browser
  34407. * @param blob defines the blob to download
  34408. * @param fileName defines the name of the downloaded file
  34409. */
  34410. static Download(blob: Blob, fileName: string): void;
  34411. /**
  34412. * Captures a screenshot of the current rendering
  34413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34414. * @param engine defines the rendering engine
  34415. * @param camera defines the source camera
  34416. * @param size This parameter can be set to a single number or to an object with the
  34417. * following (optional) properties: precision, width, height. If a single number is passed,
  34418. * it will be used for both width and height. If an object is passed, the screenshot size
  34419. * will be derived from the parameters. The precision property is a multiplier allowing
  34420. * rendering at a higher or lower resolution
  34421. * @param successCallback defines the callback receives a single parameter which contains the
  34422. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34423. * src parameter of an <img> to display it
  34424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34425. * Check your browser for supported MIME types
  34426. */
  34427. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34428. /**
  34429. * Captures a screenshot of the current rendering
  34430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34431. * @param engine defines the rendering engine
  34432. * @param camera defines the source camera
  34433. * @param size This parameter can be set to a single number or to an object with the
  34434. * following (optional) properties: precision, width, height. If a single number is passed,
  34435. * it will be used for both width and height. If an object is passed, the screenshot size
  34436. * will be derived from the parameters. The precision property is a multiplier allowing
  34437. * rendering at a higher or lower resolution
  34438. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34439. * Check your browser for supported MIME types
  34440. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34441. * to the src parameter of an <img> to display it
  34442. */
  34443. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34444. /**
  34445. * Generates an image screenshot from the specified camera.
  34446. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34447. * @param engine The engine to use for rendering
  34448. * @param camera The camera to use for rendering
  34449. * @param size This parameter can be set to a single number or to an object with the
  34450. * following (optional) properties: precision, width, height. If a single number is passed,
  34451. * it will be used for both width and height. If an object is passed, the screenshot size
  34452. * will be derived from the parameters. The precision property is a multiplier allowing
  34453. * rendering at a higher or lower resolution
  34454. * @param successCallback The callback receives a single parameter which contains the
  34455. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34456. * src parameter of an <img> to display it
  34457. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34458. * Check your browser for supported MIME types
  34459. * @param samples Texture samples (default: 1)
  34460. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34461. * @param fileName A name for for the downloaded file.
  34462. */
  34463. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34464. /**
  34465. * Generates an image screenshot from the specified camera.
  34466. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34467. * @param engine The engine to use for rendering
  34468. * @param camera The camera to use for rendering
  34469. * @param size This parameter can be set to a single number or to an object with the
  34470. * following (optional) properties: precision, width, height. If a single number is passed,
  34471. * it will be used for both width and height. If an object is passed, the screenshot size
  34472. * will be derived from the parameters. The precision property is a multiplier allowing
  34473. * rendering at a higher or lower resolution
  34474. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34475. * Check your browser for supported MIME types
  34476. * @param samples Texture samples (default: 1)
  34477. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34478. * @param fileName A name for for the downloaded file.
  34479. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34480. * to the src parameter of an <img> to display it
  34481. */
  34482. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34483. /**
  34484. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34485. * Be aware Math.random() could cause collisions, but:
  34486. * "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"
  34487. * @returns a pseudo random id
  34488. */
  34489. static RandomId(): string;
  34490. /**
  34491. * Test if the given uri is a base64 string
  34492. * @param uri The uri to test
  34493. * @return True if the uri is a base64 string or false otherwise
  34494. */
  34495. static IsBase64(uri: string): boolean;
  34496. /**
  34497. * Decode the given base64 uri.
  34498. * @param uri The uri to decode
  34499. * @return The decoded base64 data.
  34500. */
  34501. static DecodeBase64(uri: string): ArrayBuffer;
  34502. /**
  34503. * Gets the absolute url.
  34504. * @param url the input url
  34505. * @return the absolute url
  34506. */
  34507. static GetAbsoluteUrl(url: string): string;
  34508. /**
  34509. * No log
  34510. */
  34511. static readonly NoneLogLevel: number;
  34512. /**
  34513. * Only message logs
  34514. */
  34515. static readonly MessageLogLevel: number;
  34516. /**
  34517. * Only warning logs
  34518. */
  34519. static readonly WarningLogLevel: number;
  34520. /**
  34521. * Only error logs
  34522. */
  34523. static readonly ErrorLogLevel: number;
  34524. /**
  34525. * All logs
  34526. */
  34527. static readonly AllLogLevel: number;
  34528. /**
  34529. * Gets a value indicating the number of loading errors
  34530. * @ignorenaming
  34531. */
  34532. static get errorsCount(): number;
  34533. /**
  34534. * Callback called when a new log is added
  34535. */
  34536. static OnNewCacheEntry: (entry: string) => void;
  34537. /**
  34538. * Log a message to the console
  34539. * @param message defines the message to log
  34540. */
  34541. static Log(message: string): void;
  34542. /**
  34543. * Write a warning message to the console
  34544. * @param message defines the message to log
  34545. */
  34546. static Warn(message: string): void;
  34547. /**
  34548. * Write an error message to the console
  34549. * @param message defines the message to log
  34550. */
  34551. static Error(message: string): void;
  34552. /**
  34553. * Gets current log cache (list of logs)
  34554. */
  34555. static get LogCache(): string;
  34556. /**
  34557. * Clears the log cache
  34558. */
  34559. static ClearLogCache(): void;
  34560. /**
  34561. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34562. */
  34563. static set LogLevels(level: number);
  34564. /**
  34565. * Checks if the window object exists
  34566. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34567. */
  34568. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34569. /**
  34570. * No performance log
  34571. */
  34572. static readonly PerformanceNoneLogLevel: number;
  34573. /**
  34574. * Use user marks to log performance
  34575. */
  34576. static readonly PerformanceUserMarkLogLevel: number;
  34577. /**
  34578. * Log performance to the console
  34579. */
  34580. static readonly PerformanceConsoleLogLevel: number;
  34581. private static _performance;
  34582. /**
  34583. * Sets the current performance log level
  34584. */
  34585. static set PerformanceLogLevel(level: number);
  34586. private static _StartPerformanceCounterDisabled;
  34587. private static _EndPerformanceCounterDisabled;
  34588. private static _StartUserMark;
  34589. private static _EndUserMark;
  34590. private static _StartPerformanceConsole;
  34591. private static _EndPerformanceConsole;
  34592. /**
  34593. * Starts a performance counter
  34594. */
  34595. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34596. /**
  34597. * Ends a specific performance coutner
  34598. */
  34599. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34600. /**
  34601. * Gets either window.performance.now() if supported or Date.now() else
  34602. */
  34603. static get Now(): number;
  34604. /**
  34605. * This method will return the name of the class used to create the instance of the given object.
  34606. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34607. * @param object the object to get the class name from
  34608. * @param isType defines if the object is actually a type
  34609. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34610. */
  34611. static GetClassName(object: any, isType?: boolean): string;
  34612. /**
  34613. * Gets the first element of an array satisfying a given predicate
  34614. * @param array defines the array to browse
  34615. * @param predicate defines the predicate to use
  34616. * @returns null if not found or the element
  34617. */
  34618. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34619. /**
  34620. * This method will return the name of the full name of the class, including its owning module (if any).
  34621. * 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).
  34622. * @param object the object to get the class name from
  34623. * @param isType defines if the object is actually a type
  34624. * @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.
  34625. * @ignorenaming
  34626. */
  34627. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34628. /**
  34629. * Returns a promise that resolves after the given amount of time.
  34630. * @param delay Number of milliseconds to delay
  34631. * @returns Promise that resolves after the given amount of time
  34632. */
  34633. static DelayAsync(delay: number): Promise<void>;
  34634. /**
  34635. * Utility function to detect if the current user agent is Safari
  34636. * @returns whether or not the current user agent is safari
  34637. */
  34638. static IsSafari(): boolean;
  34639. }
  34640. /**
  34641. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34642. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34643. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34644. * @param name The name of the class, case should be preserved
  34645. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34646. */
  34647. export function className(name: string, module?: string): (target: Object) => void;
  34648. /**
  34649. * An implementation of a loop for asynchronous functions.
  34650. */
  34651. export class AsyncLoop {
  34652. /**
  34653. * Defines the number of iterations for the loop
  34654. */
  34655. iterations: number;
  34656. /**
  34657. * Defines the current index of the loop.
  34658. */
  34659. index: number;
  34660. private _done;
  34661. private _fn;
  34662. private _successCallback;
  34663. /**
  34664. * Constructor.
  34665. * @param iterations the number of iterations.
  34666. * @param func the function to run each iteration
  34667. * @param successCallback the callback that will be called upon succesful execution
  34668. * @param offset starting offset.
  34669. */
  34670. constructor(
  34671. /**
  34672. * Defines the number of iterations for the loop
  34673. */
  34674. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34675. /**
  34676. * Execute the next iteration. Must be called after the last iteration was finished.
  34677. */
  34678. executeNext(): void;
  34679. /**
  34680. * Break the loop and run the success callback.
  34681. */
  34682. breakLoop(): void;
  34683. /**
  34684. * Create and run an async loop.
  34685. * @param iterations the number of iterations.
  34686. * @param fn the function to run each iteration
  34687. * @param successCallback the callback that will be called upon succesful execution
  34688. * @param offset starting offset.
  34689. * @returns the created async loop object
  34690. */
  34691. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34692. /**
  34693. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34694. * @param iterations total number of iterations
  34695. * @param syncedIterations number of synchronous iterations in each async iteration.
  34696. * @param fn the function to call each iteration.
  34697. * @param callback a success call back that will be called when iterating stops.
  34698. * @param breakFunction a break condition (optional)
  34699. * @param timeout timeout settings for the setTimeout function. default - 0.
  34700. * @returns the created async loop object
  34701. */
  34702. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34703. }
  34704. }
  34705. declare module BABYLON {
  34706. /**
  34707. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34708. * The underlying implementation relies on an associative array to ensure the best performances.
  34709. * The value can be anything including 'null' but except 'undefined'
  34710. */
  34711. export class StringDictionary<T> {
  34712. /**
  34713. * This will clear this dictionary and copy the content from the 'source' one.
  34714. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34715. * @param source the dictionary to take the content from and copy to this dictionary
  34716. */
  34717. copyFrom(source: StringDictionary<T>): void;
  34718. /**
  34719. * Get a value based from its key
  34720. * @param key the given key to get the matching value from
  34721. * @return the value if found, otherwise undefined is returned
  34722. */
  34723. get(key: string): T | undefined;
  34724. /**
  34725. * Get a value from its key or add it if it doesn't exist.
  34726. * This method will ensure you that a given key/data will be present in the dictionary.
  34727. * @param key the given key to get the matching value from
  34728. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34729. * The factory will only be invoked if there's no data for the given key.
  34730. * @return the value corresponding to the key.
  34731. */
  34732. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34733. /**
  34734. * Get a value from its key if present in the dictionary otherwise add it
  34735. * @param key the key to get the value from
  34736. * @param val if there's no such key/value pair in the dictionary add it with this value
  34737. * @return the value corresponding to the key
  34738. */
  34739. getOrAdd(key: string, val: T): T;
  34740. /**
  34741. * Check if there's a given key in the dictionary
  34742. * @param key the key to check for
  34743. * @return true if the key is present, false otherwise
  34744. */
  34745. contains(key: string): boolean;
  34746. /**
  34747. * Add a new key and its corresponding value
  34748. * @param key the key to add
  34749. * @param value the value corresponding to the key
  34750. * @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
  34751. */
  34752. add(key: string, value: T): boolean;
  34753. /**
  34754. * Update a specific value associated to a key
  34755. * @param key defines the key to use
  34756. * @param value defines the value to store
  34757. * @returns true if the value was updated (or false if the key was not found)
  34758. */
  34759. set(key: string, value: T): boolean;
  34760. /**
  34761. * Get the element of the given key and remove it from the dictionary
  34762. * @param key defines the key to search
  34763. * @returns the value associated with the key or null if not found
  34764. */
  34765. getAndRemove(key: string): Nullable<T>;
  34766. /**
  34767. * Remove a key/value from the dictionary.
  34768. * @param key the key to remove
  34769. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34770. */
  34771. remove(key: string): boolean;
  34772. /**
  34773. * Clear the whole content of the dictionary
  34774. */
  34775. clear(): void;
  34776. /**
  34777. * Gets the current count
  34778. */
  34779. get count(): number;
  34780. /**
  34781. * Execute a callback on each key/val of the dictionary.
  34782. * Note that you can remove any element in this dictionary in the callback implementation
  34783. * @param callback the callback to execute on a given key/value pair
  34784. */
  34785. forEach(callback: (key: string, val: T) => void): void;
  34786. /**
  34787. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34788. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34789. * Note that you can remove any element in this dictionary in the callback implementation
  34790. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34791. * @returns the first item
  34792. */
  34793. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34794. private _count;
  34795. private _data;
  34796. }
  34797. }
  34798. declare module BABYLON {
  34799. /** @hidden */
  34800. export interface ICollisionCoordinator {
  34801. createCollider(): Collider;
  34802. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34803. init(scene: Scene): void;
  34804. }
  34805. /** @hidden */
  34806. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34807. private _scene;
  34808. private _scaledPosition;
  34809. private _scaledVelocity;
  34810. private _finalPosition;
  34811. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34812. createCollider(): Collider;
  34813. init(scene: Scene): void;
  34814. private _collideWithWorld;
  34815. }
  34816. }
  34817. declare module BABYLON {
  34818. /**
  34819. * Class used to manage all inputs for the scene.
  34820. */
  34821. export class InputManager {
  34822. /** The distance in pixel that you have to move to prevent some events */
  34823. static DragMovementThreshold: number;
  34824. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34825. static LongPressDelay: number;
  34826. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34827. static DoubleClickDelay: number;
  34828. /** If you need to check double click without raising a single click at first click, enable this flag */
  34829. static ExclusiveDoubleClickMode: boolean;
  34830. private _wheelEventName;
  34831. private _onPointerMove;
  34832. private _onPointerDown;
  34833. private _onPointerUp;
  34834. private _initClickEvent;
  34835. private _initActionManager;
  34836. private _delayedSimpleClick;
  34837. private _delayedSimpleClickTimeout;
  34838. private _previousDelayedSimpleClickTimeout;
  34839. private _meshPickProceed;
  34840. private _previousButtonPressed;
  34841. private _currentPickResult;
  34842. private _previousPickResult;
  34843. private _totalPointersPressed;
  34844. private _doubleClickOccured;
  34845. private _pointerOverMesh;
  34846. private _pickedDownMesh;
  34847. private _pickedUpMesh;
  34848. private _pointerX;
  34849. private _pointerY;
  34850. private _unTranslatedPointerX;
  34851. private _unTranslatedPointerY;
  34852. private _startingPointerPosition;
  34853. private _previousStartingPointerPosition;
  34854. private _startingPointerTime;
  34855. private _previousStartingPointerTime;
  34856. private _pointerCaptures;
  34857. private _onKeyDown;
  34858. private _onKeyUp;
  34859. private _onCanvasFocusObserver;
  34860. private _onCanvasBlurObserver;
  34861. private _scene;
  34862. /**
  34863. * Creates a new InputManager
  34864. * @param scene defines the hosting scene
  34865. */
  34866. constructor(scene: Scene);
  34867. /**
  34868. * Gets the mesh that is currently under the pointer
  34869. */
  34870. get meshUnderPointer(): Nullable<AbstractMesh>;
  34871. /**
  34872. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34873. */
  34874. get unTranslatedPointer(): Vector2;
  34875. /**
  34876. * Gets or sets the current on-screen X position of the pointer
  34877. */
  34878. get pointerX(): number;
  34879. set pointerX(value: number);
  34880. /**
  34881. * Gets or sets the current on-screen Y position of the pointer
  34882. */
  34883. get pointerY(): number;
  34884. set pointerY(value: number);
  34885. private _updatePointerPosition;
  34886. private _processPointerMove;
  34887. private _setRayOnPointerInfo;
  34888. private _checkPrePointerObservable;
  34889. /**
  34890. * Use this method to simulate a pointer move on a mesh
  34891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34894. */
  34895. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34896. /**
  34897. * Use this method to simulate a pointer down on a mesh
  34898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34901. */
  34902. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34903. private _processPointerDown;
  34904. /** @hidden */
  34905. _isPointerSwiping(): boolean;
  34906. /**
  34907. * Use this method to simulate a pointer up on a mesh
  34908. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34909. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34910. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34911. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34912. */
  34913. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34914. private _processPointerUp;
  34915. /**
  34916. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34917. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34918. * @returns true if the pointer was captured
  34919. */
  34920. isPointerCaptured(pointerId?: number): boolean;
  34921. /**
  34922. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34923. * @param attachUp defines if you want to attach events to pointerup
  34924. * @param attachDown defines if you want to attach events to pointerdown
  34925. * @param attachMove defines if you want to attach events to pointermove
  34926. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34927. */
  34928. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34929. /**
  34930. * Detaches all event handlers
  34931. */
  34932. detachControl(): void;
  34933. /**
  34934. * Force the value of meshUnderPointer
  34935. * @param mesh defines the mesh to use
  34936. */
  34937. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34938. /**
  34939. * Gets the mesh under the pointer
  34940. * @returns a Mesh or null if no mesh is under the pointer
  34941. */
  34942. getPointerOverMesh(): Nullable<AbstractMesh>;
  34943. }
  34944. }
  34945. declare module BABYLON {
  34946. /**
  34947. * Helper class used to generate session unique ID
  34948. */
  34949. export class UniqueIdGenerator {
  34950. private static _UniqueIdCounter;
  34951. /**
  34952. * Gets an unique (relatively to the current scene) Id
  34953. */
  34954. static get UniqueId(): number;
  34955. }
  34956. }
  34957. declare module BABYLON {
  34958. /**
  34959. * This class defines the direct association between an animation and a target
  34960. */
  34961. export class TargetedAnimation {
  34962. /**
  34963. * Animation to perform
  34964. */
  34965. animation: Animation;
  34966. /**
  34967. * Target to animate
  34968. */
  34969. target: any;
  34970. /**
  34971. * Serialize the object
  34972. * @returns the JSON object representing the current entity
  34973. */
  34974. serialize(): any;
  34975. }
  34976. /**
  34977. * Use this class to create coordinated animations on multiple targets
  34978. */
  34979. export class AnimationGroup implements IDisposable {
  34980. /** The name of the animation group */
  34981. name: string;
  34982. private _scene;
  34983. private _targetedAnimations;
  34984. private _animatables;
  34985. private _from;
  34986. private _to;
  34987. private _isStarted;
  34988. private _isPaused;
  34989. private _speedRatio;
  34990. private _loopAnimation;
  34991. /**
  34992. * Gets or sets the unique id of the node
  34993. */
  34994. uniqueId: number;
  34995. /**
  34996. * This observable will notify when one animation have ended
  34997. */
  34998. onAnimationEndObservable: Observable<TargetedAnimation>;
  34999. /**
  35000. * Observer raised when one animation loops
  35001. */
  35002. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35003. /**
  35004. * Observer raised when all animations have looped
  35005. */
  35006. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35007. /**
  35008. * This observable will notify when all animations have ended.
  35009. */
  35010. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35011. /**
  35012. * This observable will notify when all animations have paused.
  35013. */
  35014. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35015. /**
  35016. * This observable will notify when all animations are playing.
  35017. */
  35018. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35019. /**
  35020. * Gets the first frame
  35021. */
  35022. get from(): number;
  35023. /**
  35024. * Gets the last frame
  35025. */
  35026. get to(): number;
  35027. /**
  35028. * Define if the animations are started
  35029. */
  35030. get isStarted(): boolean;
  35031. /**
  35032. * Gets a value indicating that the current group is playing
  35033. */
  35034. get isPlaying(): boolean;
  35035. /**
  35036. * Gets or sets the speed ratio to use for all animations
  35037. */
  35038. get speedRatio(): number;
  35039. /**
  35040. * Gets or sets the speed ratio to use for all animations
  35041. */
  35042. set speedRatio(value: number);
  35043. /**
  35044. * Gets or sets if all animations should loop or not
  35045. */
  35046. get loopAnimation(): boolean;
  35047. set loopAnimation(value: boolean);
  35048. /**
  35049. * Gets the targeted animations for this animation group
  35050. */
  35051. get targetedAnimations(): Array<TargetedAnimation>;
  35052. /**
  35053. * returning the list of animatables controlled by this animation group.
  35054. */
  35055. get animatables(): Array<Animatable>;
  35056. /**
  35057. * Instantiates a new Animation Group.
  35058. * This helps managing several animations at once.
  35059. * @see http://doc.babylonjs.com/how_to/group
  35060. * @param name Defines the name of the group
  35061. * @param scene Defines the scene the group belongs to
  35062. */
  35063. constructor(
  35064. /** The name of the animation group */
  35065. name: string, scene?: Nullable<Scene>);
  35066. /**
  35067. * Add an animation (with its target) in the group
  35068. * @param animation defines the animation we want to add
  35069. * @param target defines the target of the animation
  35070. * @returns the TargetedAnimation object
  35071. */
  35072. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35073. /**
  35074. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35075. * It can add constant keys at begin or end
  35076. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35077. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35078. * @returns the animation group
  35079. */
  35080. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35081. private _animationLoopCount;
  35082. private _animationLoopFlags;
  35083. private _processLoop;
  35084. /**
  35085. * Start all animations on given targets
  35086. * @param loop defines if animations must loop
  35087. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35088. * @param from defines the from key (optional)
  35089. * @param to defines the to key (optional)
  35090. * @returns the current animation group
  35091. */
  35092. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35093. /**
  35094. * Pause all animations
  35095. * @returns the animation group
  35096. */
  35097. pause(): AnimationGroup;
  35098. /**
  35099. * Play all animations to initial state
  35100. * This function will start() the animations if they were not started or will restart() them if they were paused
  35101. * @param loop defines if animations must loop
  35102. * @returns the animation group
  35103. */
  35104. play(loop?: boolean): AnimationGroup;
  35105. /**
  35106. * Reset all animations to initial state
  35107. * @returns the animation group
  35108. */
  35109. reset(): AnimationGroup;
  35110. /**
  35111. * Restart animations from key 0
  35112. * @returns the animation group
  35113. */
  35114. restart(): AnimationGroup;
  35115. /**
  35116. * Stop all animations
  35117. * @returns the animation group
  35118. */
  35119. stop(): AnimationGroup;
  35120. /**
  35121. * Set animation weight for all animatables
  35122. * @param weight defines the weight to use
  35123. * @return the animationGroup
  35124. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35125. */
  35126. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35127. /**
  35128. * Synchronize and normalize all animatables with a source animatable
  35129. * @param root defines the root animatable to synchronize with
  35130. * @return the animationGroup
  35131. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35132. */
  35133. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35134. /**
  35135. * Goes to a specific frame in this animation group
  35136. * @param frame the frame number to go to
  35137. * @return the animationGroup
  35138. */
  35139. goToFrame(frame: number): AnimationGroup;
  35140. /**
  35141. * Dispose all associated resources
  35142. */
  35143. dispose(): void;
  35144. private _checkAnimationGroupEnded;
  35145. /**
  35146. * Clone the current animation group and returns a copy
  35147. * @param newName defines the name of the new group
  35148. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35149. * @returns the new aniamtion group
  35150. */
  35151. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35152. /**
  35153. * Serializes the animationGroup to an object
  35154. * @returns Serialized object
  35155. */
  35156. serialize(): any;
  35157. /**
  35158. * Returns a new AnimationGroup object parsed from the source provided.
  35159. * @param parsedAnimationGroup defines the source
  35160. * @param scene defines the scene that will receive the animationGroup
  35161. * @returns a new AnimationGroup
  35162. */
  35163. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35164. /**
  35165. * Returns the string "AnimationGroup"
  35166. * @returns "AnimationGroup"
  35167. */
  35168. getClassName(): string;
  35169. /**
  35170. * Creates a detailled string about the object
  35171. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35172. * @returns a string representing the object
  35173. */
  35174. toString(fullDetails?: boolean): string;
  35175. }
  35176. }
  35177. declare module BABYLON {
  35178. /**
  35179. * Define an interface for all classes that will hold resources
  35180. */
  35181. export interface IDisposable {
  35182. /**
  35183. * Releases all held resources
  35184. */
  35185. dispose(): void;
  35186. }
  35187. /** Interface defining initialization parameters for Scene class */
  35188. export interface SceneOptions {
  35189. /**
  35190. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35191. * It will improve performance when the number of geometries becomes important.
  35192. */
  35193. useGeometryUniqueIdsMap?: boolean;
  35194. /**
  35195. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35196. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35197. */
  35198. useMaterialMeshMap?: boolean;
  35199. /**
  35200. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35201. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35202. */
  35203. useClonedMeshMap?: boolean;
  35204. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35205. virtual?: boolean;
  35206. }
  35207. /**
  35208. * Represents a scene to be rendered by the engine.
  35209. * @see http://doc.babylonjs.com/features/scene
  35210. */
  35211. export class Scene extends AbstractScene implements IAnimatable {
  35212. /** The fog is deactivated */
  35213. static readonly FOGMODE_NONE: number;
  35214. /** The fog density is following an exponential function */
  35215. static readonly FOGMODE_EXP: number;
  35216. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35217. static readonly FOGMODE_EXP2: number;
  35218. /** The fog density is following a linear function. */
  35219. static readonly FOGMODE_LINEAR: number;
  35220. /**
  35221. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35223. */
  35224. static MinDeltaTime: number;
  35225. /**
  35226. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35228. */
  35229. static MaxDeltaTime: number;
  35230. /**
  35231. * Factory used to create the default material.
  35232. * @param name The name of the material to create
  35233. * @param scene The scene to create the material for
  35234. * @returns The default material
  35235. */
  35236. static DefaultMaterialFactory(scene: Scene): Material;
  35237. /**
  35238. * Factory used to create the a collision coordinator.
  35239. * @returns The collision coordinator
  35240. */
  35241. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35242. /** @hidden */
  35243. _inputManager: InputManager;
  35244. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35245. cameraToUseForPointers: Nullable<Camera>;
  35246. /** @hidden */
  35247. readonly _isScene: boolean;
  35248. /** @hidden */
  35249. _blockEntityCollection: boolean;
  35250. /**
  35251. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35252. */
  35253. autoClear: boolean;
  35254. /**
  35255. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35256. */
  35257. autoClearDepthAndStencil: boolean;
  35258. /**
  35259. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35260. */
  35261. clearColor: Color4;
  35262. /**
  35263. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35264. */
  35265. ambientColor: Color3;
  35266. /**
  35267. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35268. * It should only be one of the following (if not the default embedded one):
  35269. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35270. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35271. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35272. * The material properties need to be setup according to the type of texture in use.
  35273. */
  35274. environmentBRDFTexture: BaseTexture;
  35275. /** @hidden */
  35276. protected _environmentTexture: Nullable<BaseTexture>;
  35277. /**
  35278. * Texture used in all pbr material as the reflection texture.
  35279. * As in the majority of the scene they are the same (exception for multi room and so on),
  35280. * this is easier to reference from here than from all the materials.
  35281. */
  35282. get environmentTexture(): Nullable<BaseTexture>;
  35283. /**
  35284. * Texture used in all pbr material as the reflection texture.
  35285. * As in the majority of the scene they are the same (exception for multi room and so on),
  35286. * this is easier to set here than in all the materials.
  35287. */
  35288. set environmentTexture(value: Nullable<BaseTexture>);
  35289. /** @hidden */
  35290. protected _environmentIntensity: number;
  35291. /**
  35292. * Intensity of the environment in all pbr material.
  35293. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35294. * As in the majority of the scene they are the same (exception for multi room and so on),
  35295. * this is easier to reference from here than from all the materials.
  35296. */
  35297. get environmentIntensity(): number;
  35298. /**
  35299. * Intensity of the environment in all pbr material.
  35300. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35301. * As in the majority of the scene they are the same (exception for multi room and so on),
  35302. * this is easier to set here than in all the materials.
  35303. */
  35304. set environmentIntensity(value: number);
  35305. /** @hidden */
  35306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35307. /**
  35308. * Default image processing configuration used either in the rendering
  35309. * Forward main pass or through the imageProcessingPostProcess if present.
  35310. * As in the majority of the scene they are the same (exception for multi camera),
  35311. * this is easier to reference from here than from all the materials and post process.
  35312. *
  35313. * No setter as we it is a shared configuration, you can set the values instead.
  35314. */
  35315. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35316. private _forceWireframe;
  35317. /**
  35318. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35319. */
  35320. set forceWireframe(value: boolean);
  35321. get forceWireframe(): boolean;
  35322. private _skipFrustumClipping;
  35323. /**
  35324. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35325. */
  35326. set skipFrustumClipping(value: boolean);
  35327. get skipFrustumClipping(): boolean;
  35328. private _forcePointsCloud;
  35329. /**
  35330. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35331. */
  35332. set forcePointsCloud(value: boolean);
  35333. get forcePointsCloud(): boolean;
  35334. /**
  35335. * Gets or sets the active clipplane 1
  35336. */
  35337. clipPlane: Nullable<Plane>;
  35338. /**
  35339. * Gets or sets the active clipplane 2
  35340. */
  35341. clipPlane2: Nullable<Plane>;
  35342. /**
  35343. * Gets or sets the active clipplane 3
  35344. */
  35345. clipPlane3: Nullable<Plane>;
  35346. /**
  35347. * Gets or sets the active clipplane 4
  35348. */
  35349. clipPlane4: Nullable<Plane>;
  35350. /**
  35351. * Gets or sets the active clipplane 5
  35352. */
  35353. clipPlane5: Nullable<Plane>;
  35354. /**
  35355. * Gets or sets the active clipplane 6
  35356. */
  35357. clipPlane6: Nullable<Plane>;
  35358. /**
  35359. * Gets or sets a boolean indicating if animations are enabled
  35360. */
  35361. animationsEnabled: boolean;
  35362. private _animationPropertiesOverride;
  35363. /**
  35364. * Gets or sets the animation properties override
  35365. */
  35366. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35367. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35368. /**
  35369. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35370. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35371. */
  35372. useConstantAnimationDeltaTime: boolean;
  35373. /**
  35374. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35375. * Please note that it requires to run a ray cast through the scene on every frame
  35376. */
  35377. constantlyUpdateMeshUnderPointer: boolean;
  35378. /**
  35379. * Defines the HTML cursor to use when hovering over interactive elements
  35380. */
  35381. hoverCursor: string;
  35382. /**
  35383. * Defines the HTML default cursor to use (empty by default)
  35384. */
  35385. defaultCursor: string;
  35386. /**
  35387. * Defines whether cursors are handled by the scene.
  35388. */
  35389. doNotHandleCursors: boolean;
  35390. /**
  35391. * This is used to call preventDefault() on pointer down
  35392. * in order to block unwanted artifacts like system double clicks
  35393. */
  35394. preventDefaultOnPointerDown: boolean;
  35395. /**
  35396. * This is used to call preventDefault() on pointer up
  35397. * in order to block unwanted artifacts like system double clicks
  35398. */
  35399. preventDefaultOnPointerUp: boolean;
  35400. /**
  35401. * Gets or sets user defined metadata
  35402. */
  35403. metadata: any;
  35404. /**
  35405. * For internal use only. Please do not use.
  35406. */
  35407. reservedDataStore: any;
  35408. /**
  35409. * Gets the name of the plugin used to load this scene (null by default)
  35410. */
  35411. loadingPluginName: string;
  35412. /**
  35413. * Use this array to add regular expressions used to disable offline support for specific urls
  35414. */
  35415. disableOfflineSupportExceptionRules: RegExp[];
  35416. /**
  35417. * An event triggered when the scene is disposed.
  35418. */
  35419. onDisposeObservable: Observable<Scene>;
  35420. private _onDisposeObserver;
  35421. /** Sets a function to be executed when this scene is disposed. */
  35422. set onDispose(callback: () => void);
  35423. /**
  35424. * An event triggered before rendering the scene (right after animations and physics)
  35425. */
  35426. onBeforeRenderObservable: Observable<Scene>;
  35427. private _onBeforeRenderObserver;
  35428. /** Sets a function to be executed before rendering this scene */
  35429. set beforeRender(callback: Nullable<() => void>);
  35430. /**
  35431. * An event triggered after rendering the scene
  35432. */
  35433. onAfterRenderObservable: Observable<Scene>;
  35434. /**
  35435. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35436. */
  35437. onAfterRenderCameraObservable: Observable<Camera>;
  35438. private _onAfterRenderObserver;
  35439. /** Sets a function to be executed after rendering this scene */
  35440. set afterRender(callback: Nullable<() => void>);
  35441. /**
  35442. * An event triggered before animating the scene
  35443. */
  35444. onBeforeAnimationsObservable: Observable<Scene>;
  35445. /**
  35446. * An event triggered after animations processing
  35447. */
  35448. onAfterAnimationsObservable: Observable<Scene>;
  35449. /**
  35450. * An event triggered before draw calls are ready to be sent
  35451. */
  35452. onBeforeDrawPhaseObservable: Observable<Scene>;
  35453. /**
  35454. * An event triggered after draw calls have been sent
  35455. */
  35456. onAfterDrawPhaseObservable: Observable<Scene>;
  35457. /**
  35458. * An event triggered when the scene is ready
  35459. */
  35460. onReadyObservable: Observable<Scene>;
  35461. /**
  35462. * An event triggered before rendering a camera
  35463. */
  35464. onBeforeCameraRenderObservable: Observable<Camera>;
  35465. private _onBeforeCameraRenderObserver;
  35466. /** Sets a function to be executed before rendering a camera*/
  35467. set beforeCameraRender(callback: () => void);
  35468. /**
  35469. * An event triggered after rendering a camera
  35470. */
  35471. onAfterCameraRenderObservable: Observable<Camera>;
  35472. private _onAfterCameraRenderObserver;
  35473. /** Sets a function to be executed after rendering a camera*/
  35474. set afterCameraRender(callback: () => void);
  35475. /**
  35476. * An event triggered when active meshes evaluation is about to start
  35477. */
  35478. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35479. /**
  35480. * An event triggered when active meshes evaluation is done
  35481. */
  35482. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35483. /**
  35484. * An event triggered when particles rendering is about to start
  35485. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35486. */
  35487. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35488. /**
  35489. * An event triggered when particles rendering is done
  35490. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35491. */
  35492. onAfterParticlesRenderingObservable: Observable<Scene>;
  35493. /**
  35494. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35495. */
  35496. onDataLoadedObservable: Observable<Scene>;
  35497. /**
  35498. * An event triggered when a camera is created
  35499. */
  35500. onNewCameraAddedObservable: Observable<Camera>;
  35501. /**
  35502. * An event triggered when a camera is removed
  35503. */
  35504. onCameraRemovedObservable: Observable<Camera>;
  35505. /**
  35506. * An event triggered when a light is created
  35507. */
  35508. onNewLightAddedObservable: Observable<Light>;
  35509. /**
  35510. * An event triggered when a light is removed
  35511. */
  35512. onLightRemovedObservable: Observable<Light>;
  35513. /**
  35514. * An event triggered when a geometry is created
  35515. */
  35516. onNewGeometryAddedObservable: Observable<Geometry>;
  35517. /**
  35518. * An event triggered when a geometry is removed
  35519. */
  35520. onGeometryRemovedObservable: Observable<Geometry>;
  35521. /**
  35522. * An event triggered when a transform node is created
  35523. */
  35524. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35525. /**
  35526. * An event triggered when a transform node is removed
  35527. */
  35528. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35529. /**
  35530. * An event triggered when a mesh is created
  35531. */
  35532. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35533. /**
  35534. * An event triggered when a mesh is removed
  35535. */
  35536. onMeshRemovedObservable: Observable<AbstractMesh>;
  35537. /**
  35538. * An event triggered when a skeleton is created
  35539. */
  35540. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35541. /**
  35542. * An event triggered when a skeleton is removed
  35543. */
  35544. onSkeletonRemovedObservable: Observable<Skeleton>;
  35545. /**
  35546. * An event triggered when a material is created
  35547. */
  35548. onNewMaterialAddedObservable: Observable<Material>;
  35549. /**
  35550. * An event triggered when a material is removed
  35551. */
  35552. onMaterialRemovedObservable: Observable<Material>;
  35553. /**
  35554. * An event triggered when a texture is created
  35555. */
  35556. onNewTextureAddedObservable: Observable<BaseTexture>;
  35557. /**
  35558. * An event triggered when a texture is removed
  35559. */
  35560. onTextureRemovedObservable: Observable<BaseTexture>;
  35561. /**
  35562. * An event triggered when render targets are about to be rendered
  35563. * Can happen multiple times per frame.
  35564. */
  35565. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35566. /**
  35567. * An event triggered when render targets were rendered.
  35568. * Can happen multiple times per frame.
  35569. */
  35570. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35571. /**
  35572. * An event triggered before calculating deterministic simulation step
  35573. */
  35574. onBeforeStepObservable: Observable<Scene>;
  35575. /**
  35576. * An event triggered after calculating deterministic simulation step
  35577. */
  35578. onAfterStepObservable: Observable<Scene>;
  35579. /**
  35580. * An event triggered when the activeCamera property is updated
  35581. */
  35582. onActiveCameraChanged: Observable<Scene>;
  35583. /**
  35584. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35585. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35586. * 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)
  35587. */
  35588. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35589. /**
  35590. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35591. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35592. * 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)
  35593. */
  35594. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35595. /**
  35596. * This Observable will when a mesh has been imported into the scene.
  35597. */
  35598. onMeshImportedObservable: Observable<AbstractMesh>;
  35599. /**
  35600. * This Observable will when an animation file has been imported into the scene.
  35601. */
  35602. onAnimationFileImportedObservable: Observable<Scene>;
  35603. /**
  35604. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35605. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35606. */
  35607. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35608. /** @hidden */
  35609. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35610. /**
  35611. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35612. */
  35613. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35614. /**
  35615. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35616. */
  35617. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35618. /**
  35619. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35620. */
  35621. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35622. /** Callback called when a pointer move is detected */
  35623. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35624. /** Callback called when a pointer down is detected */
  35625. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35626. /** Callback called when a pointer up is detected */
  35627. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35628. /** Callback called when a pointer pick is detected */
  35629. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35630. /**
  35631. * 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).
  35632. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35633. */
  35634. onPrePointerObservable: Observable<PointerInfoPre>;
  35635. /**
  35636. * Observable event triggered each time an input event is received from the rendering canvas
  35637. */
  35638. onPointerObservable: Observable<PointerInfo>;
  35639. /**
  35640. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35641. */
  35642. get unTranslatedPointer(): Vector2;
  35643. /**
  35644. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35645. */
  35646. static get DragMovementThreshold(): number;
  35647. static set DragMovementThreshold(value: number);
  35648. /**
  35649. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35650. */
  35651. static get LongPressDelay(): number;
  35652. static set LongPressDelay(value: number);
  35653. /**
  35654. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35655. */
  35656. static get DoubleClickDelay(): number;
  35657. static set DoubleClickDelay(value: number);
  35658. /** If you need to check double click without raising a single click at first click, enable this flag */
  35659. static get ExclusiveDoubleClickMode(): boolean;
  35660. static set ExclusiveDoubleClickMode(value: boolean);
  35661. /** @hidden */
  35662. _mirroredCameraPosition: Nullable<Vector3>;
  35663. /**
  35664. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35665. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35666. */
  35667. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35668. /**
  35669. * Observable event triggered each time an keyboard event is received from the hosting window
  35670. */
  35671. onKeyboardObservable: Observable<KeyboardInfo>;
  35672. private _useRightHandedSystem;
  35673. /**
  35674. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35675. */
  35676. set useRightHandedSystem(value: boolean);
  35677. get useRightHandedSystem(): boolean;
  35678. private _timeAccumulator;
  35679. private _currentStepId;
  35680. private _currentInternalStep;
  35681. /**
  35682. * Sets the step Id used by deterministic lock step
  35683. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35684. * @param newStepId defines the step Id
  35685. */
  35686. setStepId(newStepId: number): void;
  35687. /**
  35688. * Gets the step Id used by deterministic lock step
  35689. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35690. * @returns the step Id
  35691. */
  35692. getStepId(): number;
  35693. /**
  35694. * Gets the internal step used by deterministic lock step
  35695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35696. * @returns the internal step
  35697. */
  35698. getInternalStep(): number;
  35699. private _fogEnabled;
  35700. /**
  35701. * Gets or sets a boolean indicating if fog is enabled on this scene
  35702. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35703. * (Default is true)
  35704. */
  35705. set fogEnabled(value: boolean);
  35706. get fogEnabled(): boolean;
  35707. private _fogMode;
  35708. /**
  35709. * Gets or sets the fog mode to use
  35710. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35711. * | mode | value |
  35712. * | --- | --- |
  35713. * | FOGMODE_NONE | 0 |
  35714. * | FOGMODE_EXP | 1 |
  35715. * | FOGMODE_EXP2 | 2 |
  35716. * | FOGMODE_LINEAR | 3 |
  35717. */
  35718. set fogMode(value: number);
  35719. get fogMode(): number;
  35720. /**
  35721. * Gets or sets the fog color to use
  35722. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35723. * (Default is Color3(0.2, 0.2, 0.3))
  35724. */
  35725. fogColor: Color3;
  35726. /**
  35727. * Gets or sets the fog density to use
  35728. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35729. * (Default is 0.1)
  35730. */
  35731. fogDensity: number;
  35732. /**
  35733. * Gets or sets the fog start distance to use
  35734. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35735. * (Default is 0)
  35736. */
  35737. fogStart: number;
  35738. /**
  35739. * Gets or sets the fog end distance to use
  35740. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35741. * (Default is 1000)
  35742. */
  35743. fogEnd: number;
  35744. private _shadowsEnabled;
  35745. /**
  35746. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35747. */
  35748. set shadowsEnabled(value: boolean);
  35749. get shadowsEnabled(): boolean;
  35750. private _lightsEnabled;
  35751. /**
  35752. * Gets or sets a boolean indicating if lights are enabled on this scene
  35753. */
  35754. set lightsEnabled(value: boolean);
  35755. get lightsEnabled(): boolean;
  35756. /** All of the active cameras added to this scene. */
  35757. activeCameras: Camera[];
  35758. /** @hidden */
  35759. _activeCamera: Nullable<Camera>;
  35760. /** Gets or sets the current active camera */
  35761. get activeCamera(): Nullable<Camera>;
  35762. set activeCamera(value: Nullable<Camera>);
  35763. private _defaultMaterial;
  35764. /** The default material used on meshes when no material is affected */
  35765. get defaultMaterial(): Material;
  35766. /** The default material used on meshes when no material is affected */
  35767. set defaultMaterial(value: Material);
  35768. private _texturesEnabled;
  35769. /**
  35770. * Gets or sets a boolean indicating if textures are enabled on this scene
  35771. */
  35772. set texturesEnabled(value: boolean);
  35773. get texturesEnabled(): boolean;
  35774. /**
  35775. * Gets or sets a boolean indicating if particles are enabled on this scene
  35776. */
  35777. particlesEnabled: boolean;
  35778. /**
  35779. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35780. */
  35781. spritesEnabled: boolean;
  35782. private _skeletonsEnabled;
  35783. /**
  35784. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35785. */
  35786. set skeletonsEnabled(value: boolean);
  35787. get skeletonsEnabled(): boolean;
  35788. /**
  35789. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35790. */
  35791. lensFlaresEnabled: boolean;
  35792. /**
  35793. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35794. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35795. */
  35796. collisionsEnabled: boolean;
  35797. private _collisionCoordinator;
  35798. /** @hidden */
  35799. get collisionCoordinator(): ICollisionCoordinator;
  35800. /**
  35801. * Defines the gravity applied to this scene (used only for collisions)
  35802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35803. */
  35804. gravity: Vector3;
  35805. /**
  35806. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35807. */
  35808. postProcessesEnabled: boolean;
  35809. /**
  35810. * The list of postprocesses added to the scene
  35811. */
  35812. postProcesses: PostProcess[];
  35813. /**
  35814. * Gets the current postprocess manager
  35815. */
  35816. postProcessManager: PostProcessManager;
  35817. /**
  35818. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35819. */
  35820. renderTargetsEnabled: boolean;
  35821. /**
  35822. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35823. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35824. */
  35825. dumpNextRenderTargets: boolean;
  35826. /**
  35827. * The list of user defined render targets added to the scene
  35828. */
  35829. customRenderTargets: RenderTargetTexture[];
  35830. /**
  35831. * Defines if texture loading must be delayed
  35832. * If true, textures will only be loaded when they need to be rendered
  35833. */
  35834. useDelayedTextureLoading: boolean;
  35835. /**
  35836. * Gets the list of meshes imported to the scene through SceneLoader
  35837. */
  35838. importedMeshesFiles: String[];
  35839. /**
  35840. * Gets or sets a boolean indicating if probes are enabled on this scene
  35841. */
  35842. probesEnabled: boolean;
  35843. /**
  35844. * Gets or sets the current offline provider to use to store scene data
  35845. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35846. */
  35847. offlineProvider: IOfflineProvider;
  35848. /**
  35849. * Gets or sets the action manager associated with the scene
  35850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35851. */
  35852. actionManager: AbstractActionManager;
  35853. private _meshesForIntersections;
  35854. /**
  35855. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35856. */
  35857. proceduralTexturesEnabled: boolean;
  35858. private _engine;
  35859. private _totalVertices;
  35860. /** @hidden */
  35861. _activeIndices: PerfCounter;
  35862. /** @hidden */
  35863. _activeParticles: PerfCounter;
  35864. /** @hidden */
  35865. _activeBones: PerfCounter;
  35866. private _animationRatio;
  35867. /** @hidden */
  35868. _animationTimeLast: number;
  35869. /** @hidden */
  35870. _animationTime: number;
  35871. /**
  35872. * Gets or sets a general scale for animation speed
  35873. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35874. */
  35875. animationTimeScale: number;
  35876. /** @hidden */
  35877. _cachedMaterial: Nullable<Material>;
  35878. /** @hidden */
  35879. _cachedEffect: Nullable<Effect>;
  35880. /** @hidden */
  35881. _cachedVisibility: Nullable<number>;
  35882. private _renderId;
  35883. private _frameId;
  35884. private _executeWhenReadyTimeoutId;
  35885. private _intermediateRendering;
  35886. private _viewUpdateFlag;
  35887. private _projectionUpdateFlag;
  35888. /** @hidden */
  35889. _toBeDisposed: Nullable<IDisposable>[];
  35890. private _activeRequests;
  35891. /** @hidden */
  35892. _pendingData: any[];
  35893. private _isDisposed;
  35894. /**
  35895. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35896. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35897. */
  35898. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35899. private _activeMeshes;
  35900. private _processedMaterials;
  35901. private _renderTargets;
  35902. /** @hidden */
  35903. _activeParticleSystems: SmartArray<IParticleSystem>;
  35904. private _activeSkeletons;
  35905. private _softwareSkinnedMeshes;
  35906. private _renderingManager;
  35907. /** @hidden */
  35908. _activeAnimatables: Animatable[];
  35909. private _transformMatrix;
  35910. private _sceneUbo;
  35911. /** @hidden */
  35912. _viewMatrix: Matrix;
  35913. private _projectionMatrix;
  35914. /** @hidden */
  35915. _forcedViewPosition: Nullable<Vector3>;
  35916. /** @hidden */
  35917. _frustumPlanes: Plane[];
  35918. /**
  35919. * Gets the list of frustum planes (built from the active camera)
  35920. */
  35921. get frustumPlanes(): Plane[];
  35922. /**
  35923. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35924. * This is useful if there are more lights that the maximum simulteanous authorized
  35925. */
  35926. requireLightSorting: boolean;
  35927. /** @hidden */
  35928. readonly useMaterialMeshMap: boolean;
  35929. /** @hidden */
  35930. readonly useClonedMeshMap: boolean;
  35931. private _externalData;
  35932. private _uid;
  35933. /**
  35934. * @hidden
  35935. * Backing store of defined scene components.
  35936. */
  35937. _components: ISceneComponent[];
  35938. /**
  35939. * @hidden
  35940. * Backing store of defined scene components.
  35941. */
  35942. _serializableComponents: ISceneSerializableComponent[];
  35943. /**
  35944. * List of components to register on the next registration step.
  35945. */
  35946. private _transientComponents;
  35947. /**
  35948. * Registers the transient components if needed.
  35949. */
  35950. private _registerTransientComponents;
  35951. /**
  35952. * @hidden
  35953. * Add a component to the scene.
  35954. * Note that the ccomponent could be registered on th next frame if this is called after
  35955. * the register component stage.
  35956. * @param component Defines the component to add to the scene
  35957. */
  35958. _addComponent(component: ISceneComponent): void;
  35959. /**
  35960. * @hidden
  35961. * Gets a component from the scene.
  35962. * @param name defines the name of the component to retrieve
  35963. * @returns the component or null if not present
  35964. */
  35965. _getComponent(name: string): Nullable<ISceneComponent>;
  35966. /**
  35967. * @hidden
  35968. * Defines the actions happening before camera updates.
  35969. */
  35970. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35971. /**
  35972. * @hidden
  35973. * Defines the actions happening before clear the canvas.
  35974. */
  35975. _beforeClearStage: Stage<SimpleStageAction>;
  35976. /**
  35977. * @hidden
  35978. * Defines the actions when collecting render targets for the frame.
  35979. */
  35980. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35981. /**
  35982. * @hidden
  35983. * Defines the actions happening for one camera in the frame.
  35984. */
  35985. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35986. /**
  35987. * @hidden
  35988. * Defines the actions happening during the per mesh ready checks.
  35989. */
  35990. _isReadyForMeshStage: Stage<MeshStageAction>;
  35991. /**
  35992. * @hidden
  35993. * Defines the actions happening before evaluate active mesh checks.
  35994. */
  35995. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35996. /**
  35997. * @hidden
  35998. * Defines the actions happening during the evaluate sub mesh checks.
  35999. */
  36000. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36001. /**
  36002. * @hidden
  36003. * Defines the actions happening during the active mesh stage.
  36004. */
  36005. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36006. /**
  36007. * @hidden
  36008. * Defines the actions happening during the per camera render target step.
  36009. */
  36010. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36011. /**
  36012. * @hidden
  36013. * Defines the actions happening just before the active camera is drawing.
  36014. */
  36015. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36016. /**
  36017. * @hidden
  36018. * Defines the actions happening just before a render target is drawing.
  36019. */
  36020. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36021. /**
  36022. * @hidden
  36023. * Defines the actions happening just before a rendering group is drawing.
  36024. */
  36025. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36026. /**
  36027. * @hidden
  36028. * Defines the actions happening just before a mesh is drawing.
  36029. */
  36030. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36031. /**
  36032. * @hidden
  36033. * Defines the actions happening just after a mesh has been drawn.
  36034. */
  36035. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36036. /**
  36037. * @hidden
  36038. * Defines the actions happening just after a rendering group has been drawn.
  36039. */
  36040. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36041. /**
  36042. * @hidden
  36043. * Defines the actions happening just after the active camera has been drawn.
  36044. */
  36045. _afterCameraDrawStage: Stage<CameraStageAction>;
  36046. /**
  36047. * @hidden
  36048. * Defines the actions happening just after a render target has been drawn.
  36049. */
  36050. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36051. /**
  36052. * @hidden
  36053. * Defines the actions happening just after rendering all cameras and computing intersections.
  36054. */
  36055. _afterRenderStage: Stage<SimpleStageAction>;
  36056. /**
  36057. * @hidden
  36058. * Defines the actions happening when a pointer move event happens.
  36059. */
  36060. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36061. /**
  36062. * @hidden
  36063. * Defines the actions happening when a pointer down event happens.
  36064. */
  36065. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36066. /**
  36067. * @hidden
  36068. * Defines the actions happening when a pointer up event happens.
  36069. */
  36070. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36071. /**
  36072. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36073. */
  36074. private geometriesByUniqueId;
  36075. /**
  36076. * Creates a new Scene
  36077. * @param engine defines the engine to use to render this scene
  36078. * @param options defines the scene options
  36079. */
  36080. constructor(engine: Engine, options?: SceneOptions);
  36081. /**
  36082. * Gets a string idenfifying the name of the class
  36083. * @returns "Scene" string
  36084. */
  36085. getClassName(): string;
  36086. private _defaultMeshCandidates;
  36087. /**
  36088. * @hidden
  36089. */
  36090. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36091. private _defaultSubMeshCandidates;
  36092. /**
  36093. * @hidden
  36094. */
  36095. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36096. /**
  36097. * Sets the default candidate providers for the scene.
  36098. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36099. * and getCollidingSubMeshCandidates to their default function
  36100. */
  36101. setDefaultCandidateProviders(): void;
  36102. /**
  36103. * Gets the mesh that is currently under the pointer
  36104. */
  36105. get meshUnderPointer(): Nullable<AbstractMesh>;
  36106. /**
  36107. * Gets or sets the current on-screen X position of the pointer
  36108. */
  36109. get pointerX(): number;
  36110. set pointerX(value: number);
  36111. /**
  36112. * Gets or sets the current on-screen Y position of the pointer
  36113. */
  36114. get pointerY(): number;
  36115. set pointerY(value: number);
  36116. /**
  36117. * Gets the cached material (ie. the latest rendered one)
  36118. * @returns the cached material
  36119. */
  36120. getCachedMaterial(): Nullable<Material>;
  36121. /**
  36122. * Gets the cached effect (ie. the latest rendered one)
  36123. * @returns the cached effect
  36124. */
  36125. getCachedEffect(): Nullable<Effect>;
  36126. /**
  36127. * Gets the cached visibility state (ie. the latest rendered one)
  36128. * @returns the cached visibility state
  36129. */
  36130. getCachedVisibility(): Nullable<number>;
  36131. /**
  36132. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36133. * @param material defines the current material
  36134. * @param effect defines the current effect
  36135. * @param visibility defines the current visibility state
  36136. * @returns true if one parameter is not cached
  36137. */
  36138. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36139. /**
  36140. * Gets the engine associated with the scene
  36141. * @returns an Engine
  36142. */
  36143. getEngine(): Engine;
  36144. /**
  36145. * Gets the total number of vertices rendered per frame
  36146. * @returns the total number of vertices rendered per frame
  36147. */
  36148. getTotalVertices(): number;
  36149. /**
  36150. * Gets the performance counter for total vertices
  36151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36152. */
  36153. get totalVerticesPerfCounter(): PerfCounter;
  36154. /**
  36155. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36156. * @returns the total number of active indices rendered per frame
  36157. */
  36158. getActiveIndices(): number;
  36159. /**
  36160. * Gets the performance counter for active indices
  36161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36162. */
  36163. get totalActiveIndicesPerfCounter(): PerfCounter;
  36164. /**
  36165. * Gets the total number of active particles rendered per frame
  36166. * @returns the total number of active particles rendered per frame
  36167. */
  36168. getActiveParticles(): number;
  36169. /**
  36170. * Gets the performance counter for active particles
  36171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36172. */
  36173. get activeParticlesPerfCounter(): PerfCounter;
  36174. /**
  36175. * Gets the total number of active bones rendered per frame
  36176. * @returns the total number of active bones rendered per frame
  36177. */
  36178. getActiveBones(): number;
  36179. /**
  36180. * Gets the performance counter for active bones
  36181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36182. */
  36183. get activeBonesPerfCounter(): PerfCounter;
  36184. /**
  36185. * Gets the array of active meshes
  36186. * @returns an array of AbstractMesh
  36187. */
  36188. getActiveMeshes(): SmartArray<AbstractMesh>;
  36189. /**
  36190. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36191. * @returns a number
  36192. */
  36193. getAnimationRatio(): number;
  36194. /**
  36195. * Gets an unique Id for the current render phase
  36196. * @returns a number
  36197. */
  36198. getRenderId(): number;
  36199. /**
  36200. * Gets an unique Id for the current frame
  36201. * @returns a number
  36202. */
  36203. getFrameId(): number;
  36204. /** Call this function if you want to manually increment the render Id*/
  36205. incrementRenderId(): void;
  36206. private _createUbo;
  36207. /**
  36208. * Use this method to simulate a pointer move on a mesh
  36209. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36210. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36211. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36212. * @returns the current scene
  36213. */
  36214. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36215. /**
  36216. * Use this method to simulate a pointer down on a mesh
  36217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36220. * @returns the current scene
  36221. */
  36222. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36223. /**
  36224. * Use this method to simulate a pointer up on a mesh
  36225. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36226. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36227. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36228. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36229. * @returns the current scene
  36230. */
  36231. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36232. /**
  36233. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36234. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36235. * @returns true if the pointer was captured
  36236. */
  36237. isPointerCaptured(pointerId?: number): boolean;
  36238. /**
  36239. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36240. * @param attachUp defines if you want to attach events to pointerup
  36241. * @param attachDown defines if you want to attach events to pointerdown
  36242. * @param attachMove defines if you want to attach events to pointermove
  36243. */
  36244. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36245. /** Detaches all event handlers*/
  36246. detachControl(): void;
  36247. /**
  36248. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36249. * Delay loaded resources are not taking in account
  36250. * @return true if all required resources are ready
  36251. */
  36252. isReady(): boolean;
  36253. /** Resets all cached information relative to material (including effect and visibility) */
  36254. resetCachedMaterial(): void;
  36255. /**
  36256. * Registers a function to be called before every frame render
  36257. * @param func defines the function to register
  36258. */
  36259. registerBeforeRender(func: () => void): void;
  36260. /**
  36261. * Unregisters a function called before every frame render
  36262. * @param func defines the function to unregister
  36263. */
  36264. unregisterBeforeRender(func: () => void): void;
  36265. /**
  36266. * Registers a function to be called after every frame render
  36267. * @param func defines the function to register
  36268. */
  36269. registerAfterRender(func: () => void): void;
  36270. /**
  36271. * Unregisters a function called after every frame render
  36272. * @param func defines the function to unregister
  36273. */
  36274. unregisterAfterRender(func: () => void): void;
  36275. private _executeOnceBeforeRender;
  36276. /**
  36277. * The provided function will run before render once and will be disposed afterwards.
  36278. * A timeout delay can be provided so that the function will be executed in N ms.
  36279. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36280. * @param func The function to be executed.
  36281. * @param timeout optional delay in ms
  36282. */
  36283. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36284. /** @hidden */
  36285. _addPendingData(data: any): void;
  36286. /** @hidden */
  36287. _removePendingData(data: any): void;
  36288. /**
  36289. * Returns the number of items waiting to be loaded
  36290. * @returns the number of items waiting to be loaded
  36291. */
  36292. getWaitingItemsCount(): number;
  36293. /**
  36294. * Returns a boolean indicating if the scene is still loading data
  36295. */
  36296. get isLoading(): boolean;
  36297. /**
  36298. * Registers a function to be executed when the scene is ready
  36299. * @param {Function} func - the function to be executed
  36300. */
  36301. executeWhenReady(func: () => void): void;
  36302. /**
  36303. * Returns a promise that resolves when the scene is ready
  36304. * @returns A promise that resolves when the scene is ready
  36305. */
  36306. whenReadyAsync(): Promise<void>;
  36307. /** @hidden */
  36308. _checkIsReady(): void;
  36309. /**
  36310. * Gets all animatable attached to the scene
  36311. */
  36312. get animatables(): Animatable[];
  36313. /**
  36314. * Resets the last animation time frame.
  36315. * Useful to override when animations start running when loading a scene for the first time.
  36316. */
  36317. resetLastAnimationTimeFrame(): void;
  36318. /**
  36319. * Gets the current view matrix
  36320. * @returns a Matrix
  36321. */
  36322. getViewMatrix(): Matrix;
  36323. /**
  36324. * Gets the current projection matrix
  36325. * @returns a Matrix
  36326. */
  36327. getProjectionMatrix(): Matrix;
  36328. /**
  36329. * Gets the current transform matrix
  36330. * @returns a Matrix made of View * Projection
  36331. */
  36332. getTransformMatrix(): Matrix;
  36333. /**
  36334. * Sets the current transform matrix
  36335. * @param viewL defines the View matrix to use
  36336. * @param projectionL defines the Projection matrix to use
  36337. * @param viewR defines the right View matrix to use (if provided)
  36338. * @param projectionR defines the right Projection matrix to use (if provided)
  36339. */
  36340. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36341. /**
  36342. * Gets the uniform buffer used to store scene data
  36343. * @returns a UniformBuffer
  36344. */
  36345. getSceneUniformBuffer(): UniformBuffer;
  36346. /**
  36347. * Gets an unique (relatively to the current scene) Id
  36348. * @returns an unique number for the scene
  36349. */
  36350. getUniqueId(): number;
  36351. /**
  36352. * Add a mesh to the list of scene's meshes
  36353. * @param newMesh defines the mesh to add
  36354. * @param recursive if all child meshes should also be added to the scene
  36355. */
  36356. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36357. /**
  36358. * Remove a mesh for the list of scene's meshes
  36359. * @param toRemove defines the mesh to remove
  36360. * @param recursive if all child meshes should also be removed from the scene
  36361. * @returns the index where the mesh was in the mesh list
  36362. */
  36363. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36364. /**
  36365. * Add a transform node to the list of scene's transform nodes
  36366. * @param newTransformNode defines the transform node to add
  36367. */
  36368. addTransformNode(newTransformNode: TransformNode): void;
  36369. /**
  36370. * Remove a transform node for the list of scene's transform nodes
  36371. * @param toRemove defines the transform node to remove
  36372. * @returns the index where the transform node was in the transform node list
  36373. */
  36374. removeTransformNode(toRemove: TransformNode): number;
  36375. /**
  36376. * Remove a skeleton for the list of scene's skeletons
  36377. * @param toRemove defines the skeleton to remove
  36378. * @returns the index where the skeleton was in the skeleton list
  36379. */
  36380. removeSkeleton(toRemove: Skeleton): number;
  36381. /**
  36382. * Remove a morph target for the list of scene's morph targets
  36383. * @param toRemove defines the morph target to remove
  36384. * @returns the index where the morph target was in the morph target list
  36385. */
  36386. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36387. /**
  36388. * Remove a light for the list of scene's lights
  36389. * @param toRemove defines the light to remove
  36390. * @returns the index where the light was in the light list
  36391. */
  36392. removeLight(toRemove: Light): number;
  36393. /**
  36394. * Remove a camera for the list of scene's cameras
  36395. * @param toRemove defines the camera to remove
  36396. * @returns the index where the camera was in the camera list
  36397. */
  36398. removeCamera(toRemove: Camera): number;
  36399. /**
  36400. * Remove a particle system for the list of scene's particle systems
  36401. * @param toRemove defines the particle system to remove
  36402. * @returns the index where the particle system was in the particle system list
  36403. */
  36404. removeParticleSystem(toRemove: IParticleSystem): number;
  36405. /**
  36406. * Remove a animation for the list of scene's animations
  36407. * @param toRemove defines the animation to remove
  36408. * @returns the index where the animation was in the animation list
  36409. */
  36410. removeAnimation(toRemove: Animation): number;
  36411. /**
  36412. * Will stop the animation of the given target
  36413. * @param target - the target
  36414. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36415. * @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)
  36416. */
  36417. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36418. /**
  36419. * Removes the given animation group from this scene.
  36420. * @param toRemove The animation group to remove
  36421. * @returns The index of the removed animation group
  36422. */
  36423. removeAnimationGroup(toRemove: AnimationGroup): number;
  36424. /**
  36425. * Removes the given multi-material from this scene.
  36426. * @param toRemove The multi-material to remove
  36427. * @returns The index of the removed multi-material
  36428. */
  36429. removeMultiMaterial(toRemove: MultiMaterial): number;
  36430. /**
  36431. * Removes the given material from this scene.
  36432. * @param toRemove The material to remove
  36433. * @returns The index of the removed material
  36434. */
  36435. removeMaterial(toRemove: Material): number;
  36436. /**
  36437. * Removes the given action manager from this scene.
  36438. * @param toRemove The action manager to remove
  36439. * @returns The index of the removed action manager
  36440. */
  36441. removeActionManager(toRemove: AbstractActionManager): number;
  36442. /**
  36443. * Removes the given texture from this scene.
  36444. * @param toRemove The texture to remove
  36445. * @returns The index of the removed texture
  36446. */
  36447. removeTexture(toRemove: BaseTexture): number;
  36448. /**
  36449. * Adds the given light to this scene
  36450. * @param newLight The light to add
  36451. */
  36452. addLight(newLight: Light): void;
  36453. /**
  36454. * Sorts the list list based on light priorities
  36455. */
  36456. sortLightsByPriority(): void;
  36457. /**
  36458. * Adds the given camera to this scene
  36459. * @param newCamera The camera to add
  36460. */
  36461. addCamera(newCamera: Camera): void;
  36462. /**
  36463. * Adds the given skeleton to this scene
  36464. * @param newSkeleton The skeleton to add
  36465. */
  36466. addSkeleton(newSkeleton: Skeleton): void;
  36467. /**
  36468. * Adds the given particle system to this scene
  36469. * @param newParticleSystem The particle system to add
  36470. */
  36471. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36472. /**
  36473. * Adds the given animation to this scene
  36474. * @param newAnimation The animation to add
  36475. */
  36476. addAnimation(newAnimation: Animation): void;
  36477. /**
  36478. * Adds the given animation group to this scene.
  36479. * @param newAnimationGroup The animation group to add
  36480. */
  36481. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36482. /**
  36483. * Adds the given multi-material to this scene
  36484. * @param newMultiMaterial The multi-material to add
  36485. */
  36486. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36487. /**
  36488. * Adds the given material to this scene
  36489. * @param newMaterial The material to add
  36490. */
  36491. addMaterial(newMaterial: Material): void;
  36492. /**
  36493. * Adds the given morph target to this scene
  36494. * @param newMorphTargetManager The morph target to add
  36495. */
  36496. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36497. /**
  36498. * Adds the given geometry to this scene
  36499. * @param newGeometry The geometry to add
  36500. */
  36501. addGeometry(newGeometry: Geometry): void;
  36502. /**
  36503. * Adds the given action manager to this scene
  36504. * @param newActionManager The action manager to add
  36505. */
  36506. addActionManager(newActionManager: AbstractActionManager): void;
  36507. /**
  36508. * Adds the given texture to this scene.
  36509. * @param newTexture The texture to add
  36510. */
  36511. addTexture(newTexture: BaseTexture): void;
  36512. /**
  36513. * Switch active camera
  36514. * @param newCamera defines the new active camera
  36515. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36516. */
  36517. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36518. /**
  36519. * sets the active camera of the scene using its ID
  36520. * @param id defines the camera's ID
  36521. * @return the new active camera or null if none found.
  36522. */
  36523. setActiveCameraByID(id: string): Nullable<Camera>;
  36524. /**
  36525. * sets the active camera of the scene using its name
  36526. * @param name defines the camera's name
  36527. * @returns the new active camera or null if none found.
  36528. */
  36529. setActiveCameraByName(name: string): Nullable<Camera>;
  36530. /**
  36531. * get an animation group using its name
  36532. * @param name defines the material's name
  36533. * @return the animation group or null if none found.
  36534. */
  36535. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36536. /**
  36537. * Get a material using its unique id
  36538. * @param uniqueId defines the material's unique id
  36539. * @return the material or null if none found.
  36540. */
  36541. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36542. /**
  36543. * get a material using its id
  36544. * @param id defines the material's ID
  36545. * @return the material or null if none found.
  36546. */
  36547. getMaterialByID(id: string): Nullable<Material>;
  36548. /**
  36549. * Gets a the last added material using a given id
  36550. * @param id defines the material's ID
  36551. * @return the last material with the given id or null if none found.
  36552. */
  36553. getLastMaterialByID(id: string): Nullable<Material>;
  36554. /**
  36555. * Gets a material using its name
  36556. * @param name defines the material's name
  36557. * @return the material or null if none found.
  36558. */
  36559. getMaterialByName(name: string): Nullable<Material>;
  36560. /**
  36561. * Get a texture using its unique id
  36562. * @param uniqueId defines the texture's unique id
  36563. * @return the texture or null if none found.
  36564. */
  36565. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36566. /**
  36567. * Gets a camera using its id
  36568. * @param id defines the id to look for
  36569. * @returns the camera or null if not found
  36570. */
  36571. getCameraByID(id: string): Nullable<Camera>;
  36572. /**
  36573. * Gets a camera using its unique id
  36574. * @param uniqueId defines the unique id to look for
  36575. * @returns the camera or null if not found
  36576. */
  36577. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36578. /**
  36579. * Gets a camera using its name
  36580. * @param name defines the camera's name
  36581. * @return the camera or null if none found.
  36582. */
  36583. getCameraByName(name: string): Nullable<Camera>;
  36584. /**
  36585. * Gets a bone using its id
  36586. * @param id defines the bone's id
  36587. * @return the bone or null if not found
  36588. */
  36589. getBoneByID(id: string): Nullable<Bone>;
  36590. /**
  36591. * Gets a bone using its id
  36592. * @param name defines the bone's name
  36593. * @return the bone or null if not found
  36594. */
  36595. getBoneByName(name: string): Nullable<Bone>;
  36596. /**
  36597. * Gets a light node using its name
  36598. * @param name defines the the light's name
  36599. * @return the light or null if none found.
  36600. */
  36601. getLightByName(name: string): Nullable<Light>;
  36602. /**
  36603. * Gets a light node using its id
  36604. * @param id defines the light's id
  36605. * @return the light or null if none found.
  36606. */
  36607. getLightByID(id: string): Nullable<Light>;
  36608. /**
  36609. * Gets a light node using its scene-generated unique ID
  36610. * @param uniqueId defines the light's unique id
  36611. * @return the light or null if none found.
  36612. */
  36613. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36614. /**
  36615. * Gets a particle system by id
  36616. * @param id defines the particle system id
  36617. * @return the corresponding system or null if none found
  36618. */
  36619. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36620. /**
  36621. * Gets a geometry using its ID
  36622. * @param id defines the geometry's id
  36623. * @return the geometry or null if none found.
  36624. */
  36625. getGeometryByID(id: string): Nullable<Geometry>;
  36626. private _getGeometryByUniqueID;
  36627. /**
  36628. * Add a new geometry to this scene
  36629. * @param geometry defines the geometry to be added to the scene.
  36630. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36631. * @return a boolean defining if the geometry was added or not
  36632. */
  36633. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36634. /**
  36635. * Removes an existing geometry
  36636. * @param geometry defines the geometry to be removed from the scene
  36637. * @return a boolean defining if the geometry was removed or not
  36638. */
  36639. removeGeometry(geometry: Geometry): boolean;
  36640. /**
  36641. * Gets the list of geometries attached to the scene
  36642. * @returns an array of Geometry
  36643. */
  36644. getGeometries(): Geometry[];
  36645. /**
  36646. * Gets the first added mesh found of a given ID
  36647. * @param id defines the id to search for
  36648. * @return the mesh found or null if not found at all
  36649. */
  36650. getMeshByID(id: string): Nullable<AbstractMesh>;
  36651. /**
  36652. * Gets a list of meshes using their id
  36653. * @param id defines the id to search for
  36654. * @returns a list of meshes
  36655. */
  36656. getMeshesByID(id: string): Array<AbstractMesh>;
  36657. /**
  36658. * Gets the first added transform node found of a given ID
  36659. * @param id defines the id to search for
  36660. * @return the found transform node or null if not found at all.
  36661. */
  36662. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36663. /**
  36664. * Gets a transform node with its auto-generated unique id
  36665. * @param uniqueId efines the unique id to search for
  36666. * @return the found transform node or null if not found at all.
  36667. */
  36668. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36669. /**
  36670. * Gets a list of transform nodes using their id
  36671. * @param id defines the id to search for
  36672. * @returns a list of transform nodes
  36673. */
  36674. getTransformNodesByID(id: string): Array<TransformNode>;
  36675. /**
  36676. * Gets a mesh with its auto-generated unique id
  36677. * @param uniqueId defines the unique id to search for
  36678. * @return the found mesh or null if not found at all.
  36679. */
  36680. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36681. /**
  36682. * Gets a the last added mesh using a given id
  36683. * @param id defines the id to search for
  36684. * @return the found mesh or null if not found at all.
  36685. */
  36686. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36687. /**
  36688. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36689. * @param id defines the id to search for
  36690. * @return the found node or null if not found at all
  36691. */
  36692. getLastEntryByID(id: string): Nullable<Node>;
  36693. /**
  36694. * Gets a node (Mesh, Camera, Light) using a given id
  36695. * @param id defines the id to search for
  36696. * @return the found node or null if not found at all
  36697. */
  36698. getNodeByID(id: string): Nullable<Node>;
  36699. /**
  36700. * Gets a node (Mesh, Camera, Light) using a given name
  36701. * @param name defines the name to search for
  36702. * @return the found node or null if not found at all.
  36703. */
  36704. getNodeByName(name: string): Nullable<Node>;
  36705. /**
  36706. * Gets a mesh using a given name
  36707. * @param name defines the name to search for
  36708. * @return the found mesh or null if not found at all.
  36709. */
  36710. getMeshByName(name: string): Nullable<AbstractMesh>;
  36711. /**
  36712. * Gets a transform node using a given name
  36713. * @param name defines the name to search for
  36714. * @return the found transform node or null if not found at all.
  36715. */
  36716. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36717. /**
  36718. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36719. * @param id defines the id to search for
  36720. * @return the found skeleton or null if not found at all.
  36721. */
  36722. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36723. /**
  36724. * Gets a skeleton using a given auto generated unique id
  36725. * @param uniqueId defines the unique id to search for
  36726. * @return the found skeleton or null if not found at all.
  36727. */
  36728. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36729. /**
  36730. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36731. * @param id defines the id to search for
  36732. * @return the found skeleton or null if not found at all.
  36733. */
  36734. getSkeletonById(id: string): Nullable<Skeleton>;
  36735. /**
  36736. * Gets a skeleton using a given name
  36737. * @param name defines the name to search for
  36738. * @return the found skeleton or null if not found at all.
  36739. */
  36740. getSkeletonByName(name: string): Nullable<Skeleton>;
  36741. /**
  36742. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36743. * @param id defines the id to search for
  36744. * @return the found morph target manager or null if not found at all.
  36745. */
  36746. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36747. /**
  36748. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36749. * @param id defines the id to search for
  36750. * @return the found morph target or null if not found at all.
  36751. */
  36752. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36753. /**
  36754. * Gets a boolean indicating if the given mesh is active
  36755. * @param mesh defines the mesh to look for
  36756. * @returns true if the mesh is in the active list
  36757. */
  36758. isActiveMesh(mesh: AbstractMesh): boolean;
  36759. /**
  36760. * Return a unique id as a string which can serve as an identifier for the scene
  36761. */
  36762. get uid(): string;
  36763. /**
  36764. * Add an externaly attached data from its key.
  36765. * This method call will fail and return false, if such key already exists.
  36766. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36767. * @param key the unique key that identifies the data
  36768. * @param data the data object to associate to the key for this Engine instance
  36769. * @return true if no such key were already present and the data was added successfully, false otherwise
  36770. */
  36771. addExternalData<T>(key: string, data: T): boolean;
  36772. /**
  36773. * Get an externaly attached data from its key
  36774. * @param key the unique key that identifies the data
  36775. * @return the associated data, if present (can be null), or undefined if not present
  36776. */
  36777. getExternalData<T>(key: string): Nullable<T>;
  36778. /**
  36779. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36780. * @param key the unique key that identifies the data
  36781. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36782. * @return the associated data, can be null if the factory returned null.
  36783. */
  36784. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36785. /**
  36786. * Remove an externaly attached data from the Engine instance
  36787. * @param key the unique key that identifies the data
  36788. * @return true if the data was successfully removed, false if it doesn't exist
  36789. */
  36790. removeExternalData(key: string): boolean;
  36791. private _evaluateSubMesh;
  36792. /**
  36793. * Clear the processed materials smart array preventing retention point in material dispose.
  36794. */
  36795. freeProcessedMaterials(): void;
  36796. private _preventFreeActiveMeshesAndRenderingGroups;
  36797. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36798. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36799. * when disposing several meshes in a row or a hierarchy of meshes.
  36800. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36801. */
  36802. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36803. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36804. /**
  36805. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36806. */
  36807. freeActiveMeshes(): void;
  36808. /**
  36809. * Clear the info related to rendering groups preventing retention points during dispose.
  36810. */
  36811. freeRenderingGroups(): void;
  36812. /** @hidden */
  36813. _isInIntermediateRendering(): boolean;
  36814. /**
  36815. * Lambda returning the list of potentially active meshes.
  36816. */
  36817. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36818. /**
  36819. * Lambda returning the list of potentially active sub meshes.
  36820. */
  36821. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36822. /**
  36823. * Lambda returning the list of potentially intersecting sub meshes.
  36824. */
  36825. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36826. /**
  36827. * Lambda returning the list of potentially colliding sub meshes.
  36828. */
  36829. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36830. private _activeMeshesFrozen;
  36831. private _skipEvaluateActiveMeshesCompletely;
  36832. /**
  36833. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36834. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36835. * @returns the current scene
  36836. */
  36837. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36838. /**
  36839. * Use this function to restart evaluating active meshes on every frame
  36840. * @returns the current scene
  36841. */
  36842. unfreezeActiveMeshes(): Scene;
  36843. private _evaluateActiveMeshes;
  36844. private _activeMesh;
  36845. /**
  36846. * Update the transform matrix to update from the current active camera
  36847. * @param force defines a boolean used to force the update even if cache is up to date
  36848. */
  36849. updateTransformMatrix(force?: boolean): void;
  36850. private _bindFrameBuffer;
  36851. /** @hidden */
  36852. _allowPostProcessClearColor: boolean;
  36853. /** @hidden */
  36854. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36855. private _processSubCameras;
  36856. private _checkIntersections;
  36857. /** @hidden */
  36858. _advancePhysicsEngineStep(step: number): void;
  36859. /**
  36860. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36861. */
  36862. getDeterministicFrameTime: () => number;
  36863. /** @hidden */
  36864. _animate(): void;
  36865. /** Execute all animations (for a frame) */
  36866. animate(): void;
  36867. /**
  36868. * Render the scene
  36869. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36870. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36871. */
  36872. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36873. /**
  36874. * Freeze all materials
  36875. * A frozen material will not be updatable but should be faster to render
  36876. */
  36877. freezeMaterials(): void;
  36878. /**
  36879. * Unfreeze all materials
  36880. * A frozen material will not be updatable but should be faster to render
  36881. */
  36882. unfreezeMaterials(): void;
  36883. /**
  36884. * Releases all held ressources
  36885. */
  36886. dispose(): void;
  36887. /**
  36888. * Gets if the scene is already disposed
  36889. */
  36890. get isDisposed(): boolean;
  36891. /**
  36892. * Call this function to reduce memory footprint of the scene.
  36893. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36894. */
  36895. clearCachedVertexData(): void;
  36896. /**
  36897. * This function will remove the local cached buffer data from texture.
  36898. * It will save memory but will prevent the texture from being rebuilt
  36899. */
  36900. cleanCachedTextureBuffer(): void;
  36901. /**
  36902. * Get the world extend vectors with an optional filter
  36903. *
  36904. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36905. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36906. */
  36907. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36908. min: Vector3;
  36909. max: Vector3;
  36910. };
  36911. /**
  36912. * Creates a ray that can be used to pick in the scene
  36913. * @param x defines the x coordinate of the origin (on-screen)
  36914. * @param y defines the y coordinate of the origin (on-screen)
  36915. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36916. * @param camera defines the camera to use for the picking
  36917. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36918. * @returns a Ray
  36919. */
  36920. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36921. /**
  36922. * Creates a ray that can be used to pick in the scene
  36923. * @param x defines the x coordinate of the origin (on-screen)
  36924. * @param y defines the y coordinate of the origin (on-screen)
  36925. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36926. * @param result defines the ray where to store the picking ray
  36927. * @param camera defines the camera to use for the picking
  36928. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36929. * @returns the current scene
  36930. */
  36931. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36932. /**
  36933. * Creates a ray that can be used to pick in the scene
  36934. * @param x defines the x coordinate of the origin (on-screen)
  36935. * @param y defines the y coordinate of the origin (on-screen)
  36936. * @param camera defines the camera to use for the picking
  36937. * @returns a Ray
  36938. */
  36939. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36940. /**
  36941. * Creates a ray that can be used to pick in the scene
  36942. * @param x defines the x coordinate of the origin (on-screen)
  36943. * @param y defines the y coordinate of the origin (on-screen)
  36944. * @param result defines the ray where to store the picking ray
  36945. * @param camera defines the camera to use for the picking
  36946. * @returns the current scene
  36947. */
  36948. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36949. /** Launch a ray to try to pick a mesh in the scene
  36950. * @param x position on screen
  36951. * @param y position on screen
  36952. * @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
  36953. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36954. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36955. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36956. * @returns a PickingInfo
  36957. */
  36958. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36959. /** Use the given ray to pick a mesh in the scene
  36960. * @param ray The ray to use to pick meshes
  36961. * @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
  36962. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36963. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36964. * @returns a PickingInfo
  36965. */
  36966. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36967. /**
  36968. * Launch a ray to try to pick a mesh in the scene
  36969. * @param x X position on screen
  36970. * @param y Y position on screen
  36971. * @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
  36972. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36973. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36974. * @returns an array of PickingInfo
  36975. */
  36976. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36977. /**
  36978. * Launch a ray to try to pick a mesh in the scene
  36979. * @param ray Ray to use
  36980. * @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
  36981. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36982. * @returns an array of PickingInfo
  36983. */
  36984. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36985. /**
  36986. * Force the value of meshUnderPointer
  36987. * @param mesh defines the mesh to use
  36988. */
  36989. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36990. /**
  36991. * Gets the mesh under the pointer
  36992. * @returns a Mesh or null if no mesh is under the pointer
  36993. */
  36994. getPointerOverMesh(): Nullable<AbstractMesh>;
  36995. /** @hidden */
  36996. _rebuildGeometries(): void;
  36997. /** @hidden */
  36998. _rebuildTextures(): void;
  36999. private _getByTags;
  37000. /**
  37001. * Get a list of meshes by tags
  37002. * @param tagsQuery defines the tags query to use
  37003. * @param forEach defines a predicate used to filter results
  37004. * @returns an array of Mesh
  37005. */
  37006. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37007. /**
  37008. * Get a list of cameras by tags
  37009. * @param tagsQuery defines the tags query to use
  37010. * @param forEach defines a predicate used to filter results
  37011. * @returns an array of Camera
  37012. */
  37013. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37014. /**
  37015. * Get a list of lights by tags
  37016. * @param tagsQuery defines the tags query to use
  37017. * @param forEach defines a predicate used to filter results
  37018. * @returns an array of Light
  37019. */
  37020. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37021. /**
  37022. * Get a list of materials by tags
  37023. * @param tagsQuery defines the tags query to use
  37024. * @param forEach defines a predicate used to filter results
  37025. * @returns an array of Material
  37026. */
  37027. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37028. /**
  37029. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37030. * This allowed control for front to back rendering or reversly depending of the special needs.
  37031. *
  37032. * @param renderingGroupId The rendering group id corresponding to its index
  37033. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37034. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37035. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37036. */
  37037. 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;
  37038. /**
  37039. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37040. *
  37041. * @param renderingGroupId The rendering group id corresponding to its index
  37042. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37043. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37044. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37045. */
  37046. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37047. /**
  37048. * Gets the current auto clear configuration for one rendering group of the rendering
  37049. * manager.
  37050. * @param index the rendering group index to get the information for
  37051. * @returns The auto clear setup for the requested rendering group
  37052. */
  37053. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37054. private _blockMaterialDirtyMechanism;
  37055. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37056. get blockMaterialDirtyMechanism(): boolean;
  37057. set blockMaterialDirtyMechanism(value: boolean);
  37058. /**
  37059. * Will flag all materials as dirty to trigger new shader compilation
  37060. * @param flag defines the flag used to specify which material part must be marked as dirty
  37061. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37062. */
  37063. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37064. /** @hidden */
  37065. _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;
  37066. /** @hidden */
  37067. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37068. /** @hidden */
  37069. _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;
  37070. /** @hidden */
  37071. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37072. /** @hidden */
  37073. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37074. /** @hidden */
  37075. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Set of assets to keep when moving a scene into an asset container.
  37081. */
  37082. export class KeepAssets extends AbstractScene {
  37083. }
  37084. /**
  37085. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37086. */
  37087. export class InstantiatedEntries {
  37088. /**
  37089. * List of new root nodes (eg. nodes with no parent)
  37090. */
  37091. rootNodes: TransformNode[];
  37092. /**
  37093. * List of new skeletons
  37094. */
  37095. skeletons: Skeleton[];
  37096. /**
  37097. * List of new animation groups
  37098. */
  37099. animationGroups: AnimationGroup[];
  37100. }
  37101. /**
  37102. * Container with a set of assets that can be added or removed from a scene.
  37103. */
  37104. export class AssetContainer extends AbstractScene {
  37105. private _wasAddedToScene;
  37106. /**
  37107. * The scene the AssetContainer belongs to.
  37108. */
  37109. scene: Scene;
  37110. /**
  37111. * Instantiates an AssetContainer.
  37112. * @param scene The scene the AssetContainer belongs to.
  37113. */
  37114. constructor(scene: Scene);
  37115. /**
  37116. * Instantiate or clone all meshes and add the new ones to the scene.
  37117. * Skeletons and animation groups will all be cloned
  37118. * @param nameFunction defines an optional function used to get new names for clones
  37119. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37120. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37121. */
  37122. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37123. /**
  37124. * Adds all the assets from the container to the scene.
  37125. */
  37126. addAllToScene(): void;
  37127. /**
  37128. * Removes all the assets in the container from the scene
  37129. */
  37130. removeAllFromScene(): void;
  37131. /**
  37132. * Disposes all the assets in the container
  37133. */
  37134. dispose(): void;
  37135. private _moveAssets;
  37136. /**
  37137. * Removes all the assets contained in the scene and adds them to the container.
  37138. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37139. */
  37140. moveAllFromScene(keepAssets?: KeepAssets): void;
  37141. /**
  37142. * 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.
  37143. * @returns the root mesh
  37144. */
  37145. createRootMesh(): Mesh;
  37146. /**
  37147. * Merge animations from this asset container into a scene
  37148. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37149. * @param animatables set of animatables to retarget to a node from the scene
  37150. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37151. */
  37152. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37153. }
  37154. }
  37155. declare module BABYLON {
  37156. /**
  37157. * Defines how the parser contract is defined.
  37158. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37159. */
  37160. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37161. /**
  37162. * Defines how the individual parser contract is defined.
  37163. * These parser can parse an individual asset
  37164. */
  37165. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37166. /**
  37167. * Base class of the scene acting as a container for the different elements composing a scene.
  37168. * This class is dynamically extended by the different components of the scene increasing
  37169. * flexibility and reducing coupling
  37170. */
  37171. export abstract class AbstractScene {
  37172. /**
  37173. * Stores the list of available parsers in the application.
  37174. */
  37175. private static _BabylonFileParsers;
  37176. /**
  37177. * Stores the list of available individual parsers in the application.
  37178. */
  37179. private static _IndividualBabylonFileParsers;
  37180. /**
  37181. * Adds a parser in the list of available ones
  37182. * @param name Defines the name of the parser
  37183. * @param parser Defines the parser to add
  37184. */
  37185. static AddParser(name: string, parser: BabylonFileParser): void;
  37186. /**
  37187. * Gets a general parser from the list of avaialble ones
  37188. * @param name Defines the name of the parser
  37189. * @returns the requested parser or null
  37190. */
  37191. static GetParser(name: string): Nullable<BabylonFileParser>;
  37192. /**
  37193. * Adds n individual parser in the list of available ones
  37194. * @param name Defines the name of the parser
  37195. * @param parser Defines the parser to add
  37196. */
  37197. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37198. /**
  37199. * Gets an individual parser from the list of avaialble ones
  37200. * @param name Defines the name of the parser
  37201. * @returns the requested parser or null
  37202. */
  37203. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37204. /**
  37205. * Parser json data and populate both a scene and its associated container object
  37206. * @param jsonData Defines the data to parse
  37207. * @param scene Defines the scene to parse the data for
  37208. * @param container Defines the container attached to the parsing sequence
  37209. * @param rootUrl Defines the root url of the data
  37210. */
  37211. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37212. /**
  37213. * Gets the list of root nodes (ie. nodes with no parent)
  37214. */
  37215. rootNodes: Node[];
  37216. /** All of the cameras added to this scene
  37217. * @see http://doc.babylonjs.com/babylon101/cameras
  37218. */
  37219. cameras: Camera[];
  37220. /**
  37221. * All of the lights added to this scene
  37222. * @see http://doc.babylonjs.com/babylon101/lights
  37223. */
  37224. lights: Light[];
  37225. /**
  37226. * All of the (abstract) meshes added to this scene
  37227. */
  37228. meshes: AbstractMesh[];
  37229. /**
  37230. * The list of skeletons added to the scene
  37231. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37232. */
  37233. skeletons: Skeleton[];
  37234. /**
  37235. * All of the particle systems added to this scene
  37236. * @see http://doc.babylonjs.com/babylon101/particles
  37237. */
  37238. particleSystems: IParticleSystem[];
  37239. /**
  37240. * Gets a list of Animations associated with the scene
  37241. */
  37242. animations: Animation[];
  37243. /**
  37244. * All of the animation groups added to this scene
  37245. * @see http://doc.babylonjs.com/how_to/group
  37246. */
  37247. animationGroups: AnimationGroup[];
  37248. /**
  37249. * All of the multi-materials added to this scene
  37250. * @see http://doc.babylonjs.com/how_to/multi_materials
  37251. */
  37252. multiMaterials: MultiMaterial[];
  37253. /**
  37254. * All of the materials added to this scene
  37255. * In the context of a Scene, it is not supposed to be modified manually.
  37256. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37257. * Note also that the order of the Material within the array is not significant and might change.
  37258. * @see http://doc.babylonjs.com/babylon101/materials
  37259. */
  37260. materials: Material[];
  37261. /**
  37262. * The list of morph target managers added to the scene
  37263. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37264. */
  37265. morphTargetManagers: MorphTargetManager[];
  37266. /**
  37267. * The list of geometries used in the scene.
  37268. */
  37269. geometries: Geometry[];
  37270. /**
  37271. * All of the tranform nodes added to this scene
  37272. * In the context of a Scene, it is not supposed to be modified manually.
  37273. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37274. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37275. * @see http://doc.babylonjs.com/how_to/transformnode
  37276. */
  37277. transformNodes: TransformNode[];
  37278. /**
  37279. * ActionManagers available on the scene.
  37280. */
  37281. actionManagers: AbstractActionManager[];
  37282. /**
  37283. * Textures to keep.
  37284. */
  37285. textures: BaseTexture[];
  37286. /**
  37287. * Environment texture for the scene
  37288. */
  37289. environmentTexture: Nullable<BaseTexture>;
  37290. /**
  37291. * @returns all meshes, lights, cameras, transformNodes and bones
  37292. */
  37293. getNodes(): Array<Node>;
  37294. }
  37295. }
  37296. declare module BABYLON {
  37297. /**
  37298. * Interface used to define options for Sound class
  37299. */
  37300. export interface ISoundOptions {
  37301. /**
  37302. * Does the sound autoplay once loaded.
  37303. */
  37304. autoplay?: boolean;
  37305. /**
  37306. * Does the sound loop after it finishes playing once.
  37307. */
  37308. loop?: boolean;
  37309. /**
  37310. * Sound's volume
  37311. */
  37312. volume?: number;
  37313. /**
  37314. * Is it a spatial sound?
  37315. */
  37316. spatialSound?: boolean;
  37317. /**
  37318. * Maximum distance to hear that sound
  37319. */
  37320. maxDistance?: number;
  37321. /**
  37322. * Uses user defined attenuation function
  37323. */
  37324. useCustomAttenuation?: boolean;
  37325. /**
  37326. * Define the roll off factor of spatial sounds.
  37327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37328. */
  37329. rolloffFactor?: number;
  37330. /**
  37331. * Define the reference distance the sound should be heard perfectly.
  37332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37333. */
  37334. refDistance?: number;
  37335. /**
  37336. * Define the distance attenuation model the sound will follow.
  37337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37338. */
  37339. distanceModel?: string;
  37340. /**
  37341. * Defines the playback speed (1 by default)
  37342. */
  37343. playbackRate?: number;
  37344. /**
  37345. * Defines if the sound is from a streaming source
  37346. */
  37347. streaming?: boolean;
  37348. /**
  37349. * Defines an optional length (in seconds) inside the sound file
  37350. */
  37351. length?: number;
  37352. /**
  37353. * Defines an optional offset (in seconds) inside the sound file
  37354. */
  37355. offset?: number;
  37356. /**
  37357. * If true, URLs will not be required to state the audio file codec to use.
  37358. */
  37359. skipCodecCheck?: boolean;
  37360. }
  37361. /**
  37362. * Defines a sound that can be played in the application.
  37363. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37365. */
  37366. export class Sound {
  37367. /**
  37368. * The name of the sound in the scene.
  37369. */
  37370. name: string;
  37371. /**
  37372. * Does the sound autoplay once loaded.
  37373. */
  37374. autoplay: boolean;
  37375. /**
  37376. * Does the sound loop after it finishes playing once.
  37377. */
  37378. loop: boolean;
  37379. /**
  37380. * Does the sound use a custom attenuation curve to simulate the falloff
  37381. * happening when the source gets further away from the camera.
  37382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37383. */
  37384. useCustomAttenuation: boolean;
  37385. /**
  37386. * The sound track id this sound belongs to.
  37387. */
  37388. soundTrackId: number;
  37389. /**
  37390. * Is this sound currently played.
  37391. */
  37392. isPlaying: boolean;
  37393. /**
  37394. * Is this sound currently paused.
  37395. */
  37396. isPaused: boolean;
  37397. /**
  37398. * Does this sound enables spatial sound.
  37399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37400. */
  37401. spatialSound: boolean;
  37402. /**
  37403. * Define the reference distance the sound should be heard perfectly.
  37404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37405. */
  37406. refDistance: number;
  37407. /**
  37408. * Define the roll off factor of spatial sounds.
  37409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37410. */
  37411. rolloffFactor: number;
  37412. /**
  37413. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37415. */
  37416. maxDistance: number;
  37417. /**
  37418. * Define the distance attenuation model the sound will follow.
  37419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37420. */
  37421. distanceModel: string;
  37422. /**
  37423. * @hidden
  37424. * Back Compat
  37425. **/
  37426. onended: () => any;
  37427. /**
  37428. * Observable event when the current playing sound finishes.
  37429. */
  37430. onEndedObservable: Observable<Sound>;
  37431. private _panningModel;
  37432. private _playbackRate;
  37433. private _streaming;
  37434. private _startTime;
  37435. private _startOffset;
  37436. private _position;
  37437. /** @hidden */
  37438. _positionInEmitterSpace: boolean;
  37439. private _localDirection;
  37440. private _volume;
  37441. private _isReadyToPlay;
  37442. private _isDirectional;
  37443. private _readyToPlayCallback;
  37444. private _audioBuffer;
  37445. private _soundSource;
  37446. private _streamingSource;
  37447. private _soundPanner;
  37448. private _soundGain;
  37449. private _inputAudioNode;
  37450. private _outputAudioNode;
  37451. private _coneInnerAngle;
  37452. private _coneOuterAngle;
  37453. private _coneOuterGain;
  37454. private _scene;
  37455. private _connectedTransformNode;
  37456. private _customAttenuationFunction;
  37457. private _registerFunc;
  37458. private _isOutputConnected;
  37459. private _htmlAudioElement;
  37460. private _urlType;
  37461. private _length?;
  37462. private _offset?;
  37463. /** @hidden */
  37464. static _SceneComponentInitialization: (scene: Scene) => void;
  37465. /**
  37466. * Create a sound and attach it to a scene
  37467. * @param name Name of your sound
  37468. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37469. * @param scene defines the scene the sound belongs to
  37470. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37471. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37472. */
  37473. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37474. /**
  37475. * Release the sound and its associated resources
  37476. */
  37477. dispose(): void;
  37478. /**
  37479. * Gets if the sounds is ready to be played or not.
  37480. * @returns true if ready, otherwise false
  37481. */
  37482. isReady(): boolean;
  37483. private _soundLoaded;
  37484. /**
  37485. * Sets the data of the sound from an audiobuffer
  37486. * @param audioBuffer The audioBuffer containing the data
  37487. */
  37488. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37489. /**
  37490. * Updates the current sounds options such as maxdistance, loop...
  37491. * @param options A JSON object containing values named as the object properties
  37492. */
  37493. updateOptions(options: ISoundOptions): void;
  37494. private _createSpatialParameters;
  37495. private _updateSpatialParameters;
  37496. /**
  37497. * Switch the panning model to HRTF:
  37498. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37500. */
  37501. switchPanningModelToHRTF(): void;
  37502. /**
  37503. * Switch the panning model to Equal Power:
  37504. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37506. */
  37507. switchPanningModelToEqualPower(): void;
  37508. private _switchPanningModel;
  37509. /**
  37510. * Connect this sound to a sound track audio node like gain...
  37511. * @param soundTrackAudioNode the sound track audio node to connect to
  37512. */
  37513. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37514. /**
  37515. * Transform this sound into a directional source
  37516. * @param coneInnerAngle Size of the inner cone in degree
  37517. * @param coneOuterAngle Size of the outer cone in degree
  37518. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37519. */
  37520. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37521. /**
  37522. * Gets or sets the inner angle for the directional cone.
  37523. */
  37524. get directionalConeInnerAngle(): number;
  37525. /**
  37526. * Gets or sets the inner angle for the directional cone.
  37527. */
  37528. set directionalConeInnerAngle(value: number);
  37529. /**
  37530. * Gets or sets the outer angle for the directional cone.
  37531. */
  37532. get directionalConeOuterAngle(): number;
  37533. /**
  37534. * Gets or sets the outer angle for the directional cone.
  37535. */
  37536. set directionalConeOuterAngle(value: number);
  37537. /**
  37538. * Sets the position of the emitter if spatial sound is enabled
  37539. * @param newPosition Defines the new posisiton
  37540. */
  37541. setPosition(newPosition: Vector3): void;
  37542. /**
  37543. * Sets the local direction of the emitter if spatial sound is enabled
  37544. * @param newLocalDirection Defines the new local direction
  37545. */
  37546. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37547. private _updateDirection;
  37548. /** @hidden */
  37549. updateDistanceFromListener(): void;
  37550. /**
  37551. * Sets a new custom attenuation function for the sound.
  37552. * @param callback Defines the function used for the attenuation
  37553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37554. */
  37555. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37556. /**
  37557. * Play the sound
  37558. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37559. * @param offset (optional) Start the sound at a specific time in seconds
  37560. * @param length (optional) Sound duration (in seconds)
  37561. */
  37562. play(time?: number, offset?: number, length?: number): void;
  37563. private _onended;
  37564. /**
  37565. * Stop the sound
  37566. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37567. */
  37568. stop(time?: number): void;
  37569. /**
  37570. * Put the sound in pause
  37571. */
  37572. pause(): void;
  37573. /**
  37574. * Sets a dedicated volume for this sounds
  37575. * @param newVolume Define the new volume of the sound
  37576. * @param time Define time for gradual change to new volume
  37577. */
  37578. setVolume(newVolume: number, time?: number): void;
  37579. /**
  37580. * Set the sound play back rate
  37581. * @param newPlaybackRate Define the playback rate the sound should be played at
  37582. */
  37583. setPlaybackRate(newPlaybackRate: number): void;
  37584. /**
  37585. * Gets the volume of the sound.
  37586. * @returns the volume of the sound
  37587. */
  37588. getVolume(): number;
  37589. /**
  37590. * Attach the sound to a dedicated mesh
  37591. * @param transformNode The transform node to connect the sound with
  37592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37593. */
  37594. attachToMesh(transformNode: TransformNode): void;
  37595. /**
  37596. * Detach the sound from the previously attached mesh
  37597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37598. */
  37599. detachFromMesh(): void;
  37600. private _onRegisterAfterWorldMatrixUpdate;
  37601. /**
  37602. * Clone the current sound in the scene.
  37603. * @returns the new sound clone
  37604. */
  37605. clone(): Nullable<Sound>;
  37606. /**
  37607. * Gets the current underlying audio buffer containing the data
  37608. * @returns the audio buffer
  37609. */
  37610. getAudioBuffer(): Nullable<AudioBuffer>;
  37611. /**
  37612. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37613. * @returns the source node
  37614. */
  37615. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37616. /**
  37617. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37618. * @returns the gain node
  37619. */
  37620. getSoundGain(): Nullable<GainNode>;
  37621. /**
  37622. * Serializes the Sound in a JSON representation
  37623. * @returns the JSON representation of the sound
  37624. */
  37625. serialize(): any;
  37626. /**
  37627. * Parse a JSON representation of a sound to innstantiate in a given scene
  37628. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37629. * @param scene Define the scene the new parsed sound should be created in
  37630. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37631. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37632. * @returns the newly parsed sound
  37633. */
  37634. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37635. }
  37636. }
  37637. declare module BABYLON {
  37638. /**
  37639. * This defines an action helpful to play a defined sound on a triggered action.
  37640. */
  37641. export class PlaySoundAction extends Action {
  37642. private _sound;
  37643. /**
  37644. * Instantiate the action
  37645. * @param triggerOptions defines the trigger options
  37646. * @param sound defines the sound to play
  37647. * @param condition defines the trigger related conditions
  37648. */
  37649. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37650. /** @hidden */
  37651. _prepare(): void;
  37652. /**
  37653. * Execute the action and play the sound.
  37654. */
  37655. execute(): void;
  37656. /**
  37657. * Serializes the actions and its related information.
  37658. * @param parent defines the object to serialize in
  37659. * @returns the serialized object
  37660. */
  37661. serialize(parent: any): any;
  37662. }
  37663. /**
  37664. * This defines an action helpful to stop a defined sound on a triggered action.
  37665. */
  37666. export class StopSoundAction extends Action {
  37667. private _sound;
  37668. /**
  37669. * Instantiate the action
  37670. * @param triggerOptions defines the trigger options
  37671. * @param sound defines the sound to stop
  37672. * @param condition defines the trigger related conditions
  37673. */
  37674. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37675. /** @hidden */
  37676. _prepare(): void;
  37677. /**
  37678. * Execute the action and stop the sound.
  37679. */
  37680. execute(): void;
  37681. /**
  37682. * Serializes the actions and its related information.
  37683. * @param parent defines the object to serialize in
  37684. * @returns the serialized object
  37685. */
  37686. serialize(parent: any): any;
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. /**
  37691. * This defines an action responsible to change the value of a property
  37692. * by interpolating between its current value and the newly set one once triggered.
  37693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37694. */
  37695. export class InterpolateValueAction extends Action {
  37696. /**
  37697. * Defines the path of the property where the value should be interpolated
  37698. */
  37699. propertyPath: string;
  37700. /**
  37701. * Defines the target value at the end of the interpolation.
  37702. */
  37703. value: any;
  37704. /**
  37705. * Defines the time it will take for the property to interpolate to the value.
  37706. */
  37707. duration: number;
  37708. /**
  37709. * Defines if the other scene animations should be stopped when the action has been triggered
  37710. */
  37711. stopOtherAnimations?: boolean;
  37712. /**
  37713. * Defines a callback raised once the interpolation animation has been done.
  37714. */
  37715. onInterpolationDone?: () => void;
  37716. /**
  37717. * Observable triggered once the interpolation animation has been done.
  37718. */
  37719. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37720. private _target;
  37721. private _effectiveTarget;
  37722. private _property;
  37723. /**
  37724. * Instantiate the action
  37725. * @param triggerOptions defines the trigger options
  37726. * @param target defines the object containing the value to interpolate
  37727. * @param propertyPath defines the path to the property in the target object
  37728. * @param value defines the target value at the end of the interpolation
  37729. * @param duration deines the time it will take for the property to interpolate to the value.
  37730. * @param condition defines the trigger related conditions
  37731. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37732. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37733. */
  37734. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37735. /** @hidden */
  37736. _prepare(): void;
  37737. /**
  37738. * Execute the action starts the value interpolation.
  37739. */
  37740. execute(): void;
  37741. /**
  37742. * Serializes the actions and its related information.
  37743. * @param parent defines the object to serialize in
  37744. * @returns the serialized object
  37745. */
  37746. serialize(parent: any): any;
  37747. }
  37748. }
  37749. declare module BABYLON {
  37750. /**
  37751. * Options allowed during the creation of a sound track.
  37752. */
  37753. export interface ISoundTrackOptions {
  37754. /**
  37755. * The volume the sound track should take during creation
  37756. */
  37757. volume?: number;
  37758. /**
  37759. * Define if the sound track is the main sound track of the scene
  37760. */
  37761. mainTrack?: boolean;
  37762. }
  37763. /**
  37764. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37765. * It will be also used in a future release to apply effects on a specific track.
  37766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37767. */
  37768. export class SoundTrack {
  37769. /**
  37770. * The unique identifier of the sound track in the scene.
  37771. */
  37772. id: number;
  37773. /**
  37774. * The list of sounds included in the sound track.
  37775. */
  37776. soundCollection: Array<Sound>;
  37777. private _outputAudioNode;
  37778. private _scene;
  37779. private _connectedAnalyser;
  37780. private _options;
  37781. private _isInitialized;
  37782. /**
  37783. * Creates a new sound track.
  37784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37785. * @param scene Define the scene the sound track belongs to
  37786. * @param options
  37787. */
  37788. constructor(scene: Scene, options?: ISoundTrackOptions);
  37789. private _initializeSoundTrackAudioGraph;
  37790. /**
  37791. * Release the sound track and its associated resources
  37792. */
  37793. dispose(): void;
  37794. /**
  37795. * Adds a sound to this sound track
  37796. * @param sound define the cound to add
  37797. * @ignoreNaming
  37798. */
  37799. AddSound(sound: Sound): void;
  37800. /**
  37801. * Removes a sound to this sound track
  37802. * @param sound define the cound to remove
  37803. * @ignoreNaming
  37804. */
  37805. RemoveSound(sound: Sound): void;
  37806. /**
  37807. * Set a global volume for the full sound track.
  37808. * @param newVolume Define the new volume of the sound track
  37809. */
  37810. setVolume(newVolume: number): void;
  37811. /**
  37812. * Switch the panning model to HRTF:
  37813. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37815. */
  37816. switchPanningModelToHRTF(): void;
  37817. /**
  37818. * Switch the panning model to Equal Power:
  37819. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37821. */
  37822. switchPanningModelToEqualPower(): void;
  37823. /**
  37824. * Connect the sound track to an audio analyser allowing some amazing
  37825. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37827. * @param analyser The analyser to connect to the engine
  37828. */
  37829. connectToAnalyser(analyser: Analyser): void;
  37830. }
  37831. }
  37832. declare module BABYLON {
  37833. interface AbstractScene {
  37834. /**
  37835. * The list of sounds used in the scene.
  37836. */
  37837. sounds: Nullable<Array<Sound>>;
  37838. }
  37839. interface Scene {
  37840. /**
  37841. * @hidden
  37842. * Backing field
  37843. */
  37844. _mainSoundTrack: SoundTrack;
  37845. /**
  37846. * The main sound track played by the scene.
  37847. * It cotains your primary collection of sounds.
  37848. */
  37849. mainSoundTrack: SoundTrack;
  37850. /**
  37851. * The list of sound tracks added to the scene
  37852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37853. */
  37854. soundTracks: Nullable<Array<SoundTrack>>;
  37855. /**
  37856. * Gets a sound using a given name
  37857. * @param name defines the name to search for
  37858. * @return the found sound or null if not found at all.
  37859. */
  37860. getSoundByName(name: string): Nullable<Sound>;
  37861. /**
  37862. * Gets or sets if audio support is enabled
  37863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37864. */
  37865. audioEnabled: boolean;
  37866. /**
  37867. * Gets or sets if audio will be output to headphones
  37868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37869. */
  37870. headphone: boolean;
  37871. /**
  37872. * Gets or sets custom audio listener position provider
  37873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37874. */
  37875. audioListenerPositionProvider: Nullable<() => Vector3>;
  37876. /**
  37877. * Gets or sets a refresh rate when using 3D audio positioning
  37878. */
  37879. audioPositioningRefreshRate: number;
  37880. }
  37881. /**
  37882. * Defines the sound scene component responsible to manage any sounds
  37883. * in a given scene.
  37884. */
  37885. export class AudioSceneComponent implements ISceneSerializableComponent {
  37886. /**
  37887. * The component name helpfull to identify the component in the list of scene components.
  37888. */
  37889. readonly name: string;
  37890. /**
  37891. * The scene the component belongs to.
  37892. */
  37893. scene: Scene;
  37894. private _audioEnabled;
  37895. /**
  37896. * Gets whether audio is enabled or not.
  37897. * Please use related enable/disable method to switch state.
  37898. */
  37899. get audioEnabled(): boolean;
  37900. private _headphone;
  37901. /**
  37902. * Gets whether audio is outputing to headphone or not.
  37903. * Please use the according Switch methods to change output.
  37904. */
  37905. get headphone(): boolean;
  37906. /**
  37907. * Gets or sets a refresh rate when using 3D audio positioning
  37908. */
  37909. audioPositioningRefreshRate: number;
  37910. private _audioListenerPositionProvider;
  37911. /**
  37912. * Gets the current audio listener position provider
  37913. */
  37914. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37915. /**
  37916. * Sets a custom listener position for all sounds in the scene
  37917. * By default, this is the position of the first active camera
  37918. */
  37919. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37920. /**
  37921. * Creates a new instance of the component for the given scene
  37922. * @param scene Defines the scene to register the component in
  37923. */
  37924. constructor(scene: Scene);
  37925. /**
  37926. * Registers the component in a given scene
  37927. */
  37928. register(): void;
  37929. /**
  37930. * Rebuilds the elements related to this component in case of
  37931. * context lost for instance.
  37932. */
  37933. rebuild(): void;
  37934. /**
  37935. * Serializes the component data to the specified json object
  37936. * @param serializationObject The object to serialize to
  37937. */
  37938. serialize(serializationObject: any): void;
  37939. /**
  37940. * Adds all the elements from the container to the scene
  37941. * @param container the container holding the elements
  37942. */
  37943. addFromContainer(container: AbstractScene): void;
  37944. /**
  37945. * Removes all the elements in the container from the scene
  37946. * @param container contains the elements to remove
  37947. * @param dispose if the removed element should be disposed (default: false)
  37948. */
  37949. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37950. /**
  37951. * Disposes the component and the associated ressources.
  37952. */
  37953. dispose(): void;
  37954. /**
  37955. * Disables audio in the associated scene.
  37956. */
  37957. disableAudio(): void;
  37958. /**
  37959. * Enables audio in the associated scene.
  37960. */
  37961. enableAudio(): void;
  37962. /**
  37963. * Switch audio to headphone output.
  37964. */
  37965. switchAudioModeForHeadphones(): void;
  37966. /**
  37967. * Switch audio to normal speakers.
  37968. */
  37969. switchAudioModeForNormalSpeakers(): void;
  37970. private _cachedCameraDirection;
  37971. private _cachedCameraPosition;
  37972. private _lastCheck;
  37973. private _afterRender;
  37974. }
  37975. }
  37976. declare module BABYLON {
  37977. /**
  37978. * Wraps one or more Sound objects and selects one with random weight for playback.
  37979. */
  37980. export class WeightedSound {
  37981. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37982. loop: boolean;
  37983. private _coneInnerAngle;
  37984. private _coneOuterAngle;
  37985. private _volume;
  37986. /** A Sound is currently playing. */
  37987. isPlaying: boolean;
  37988. /** A Sound is currently paused. */
  37989. isPaused: boolean;
  37990. private _sounds;
  37991. private _weights;
  37992. private _currentIndex?;
  37993. /**
  37994. * Creates a new WeightedSound from the list of sounds given.
  37995. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37996. * @param sounds Array of Sounds that will be selected from.
  37997. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37998. */
  37999. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38000. /**
  38001. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38002. */
  38003. get directionalConeInnerAngle(): number;
  38004. /**
  38005. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38006. */
  38007. set directionalConeInnerAngle(value: number);
  38008. /**
  38009. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38010. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38011. */
  38012. get directionalConeOuterAngle(): number;
  38013. /**
  38014. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38015. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38016. */
  38017. set directionalConeOuterAngle(value: number);
  38018. /**
  38019. * Playback volume.
  38020. */
  38021. get volume(): number;
  38022. /**
  38023. * Playback volume.
  38024. */
  38025. set volume(value: number);
  38026. private _onended;
  38027. /**
  38028. * Suspend playback
  38029. */
  38030. pause(): void;
  38031. /**
  38032. * Stop playback
  38033. */
  38034. stop(): void;
  38035. /**
  38036. * Start playback.
  38037. * @param startOffset Position the clip head at a specific time in seconds.
  38038. */
  38039. play(startOffset?: number): void;
  38040. }
  38041. }
  38042. declare module BABYLON {
  38043. /**
  38044. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38046. */
  38047. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38048. /**
  38049. * Gets the name of the behavior.
  38050. */
  38051. get name(): string;
  38052. /**
  38053. * The easing function used by animations
  38054. */
  38055. static EasingFunction: BackEase;
  38056. /**
  38057. * The easing mode used by animations
  38058. */
  38059. static EasingMode: number;
  38060. /**
  38061. * The duration of the animation, in milliseconds
  38062. */
  38063. transitionDuration: number;
  38064. /**
  38065. * Length of the distance animated by the transition when lower radius is reached
  38066. */
  38067. lowerRadiusTransitionRange: number;
  38068. /**
  38069. * Length of the distance animated by the transition when upper radius is reached
  38070. */
  38071. upperRadiusTransitionRange: number;
  38072. private _autoTransitionRange;
  38073. /**
  38074. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38075. */
  38076. get autoTransitionRange(): boolean;
  38077. /**
  38078. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38079. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38080. */
  38081. set autoTransitionRange(value: boolean);
  38082. private _attachedCamera;
  38083. private _onAfterCheckInputsObserver;
  38084. private _onMeshTargetChangedObserver;
  38085. /**
  38086. * Initializes the behavior.
  38087. */
  38088. init(): void;
  38089. /**
  38090. * Attaches the behavior to its arc rotate camera.
  38091. * @param camera Defines the camera to attach the behavior to
  38092. */
  38093. attach(camera: ArcRotateCamera): void;
  38094. /**
  38095. * Detaches the behavior from its current arc rotate camera.
  38096. */
  38097. detach(): void;
  38098. private _radiusIsAnimating;
  38099. private _radiusBounceTransition;
  38100. private _animatables;
  38101. private _cachedWheelPrecision;
  38102. /**
  38103. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38104. * @param radiusLimit The limit to check against.
  38105. * @return Bool to indicate if at limit.
  38106. */
  38107. private _isRadiusAtLimit;
  38108. /**
  38109. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38110. * @param radiusDelta The delta by which to animate to. Can be negative.
  38111. */
  38112. private _applyBoundRadiusAnimation;
  38113. /**
  38114. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38115. */
  38116. protected _clearAnimationLocks(): void;
  38117. /**
  38118. * Stops and removes all animations that have been applied to the camera
  38119. */
  38120. stopAllAnimations(): void;
  38121. }
  38122. }
  38123. declare module BABYLON {
  38124. /**
  38125. * 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.
  38126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38127. */
  38128. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38129. /**
  38130. * Gets the name of the behavior.
  38131. */
  38132. get name(): string;
  38133. private _mode;
  38134. private _radiusScale;
  38135. private _positionScale;
  38136. private _defaultElevation;
  38137. private _elevationReturnTime;
  38138. private _elevationReturnWaitTime;
  38139. private _zoomStopsAnimation;
  38140. private _framingTime;
  38141. /**
  38142. * The easing function used by animations
  38143. */
  38144. static EasingFunction: ExponentialEase;
  38145. /**
  38146. * The easing mode used by animations
  38147. */
  38148. static EasingMode: number;
  38149. /**
  38150. * Sets the current mode used by the behavior
  38151. */
  38152. set mode(mode: number);
  38153. /**
  38154. * Gets current mode used by the behavior.
  38155. */
  38156. get mode(): number;
  38157. /**
  38158. * Sets the scale applied to the radius (1 by default)
  38159. */
  38160. set radiusScale(radius: number);
  38161. /**
  38162. * Gets the scale applied to the radius
  38163. */
  38164. get radiusScale(): number;
  38165. /**
  38166. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38167. */
  38168. set positionScale(scale: number);
  38169. /**
  38170. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38171. */
  38172. get positionScale(): number;
  38173. /**
  38174. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38175. * behaviour is triggered, in radians.
  38176. */
  38177. set defaultElevation(elevation: number);
  38178. /**
  38179. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38180. * behaviour is triggered, in radians.
  38181. */
  38182. get defaultElevation(): number;
  38183. /**
  38184. * Sets the time (in milliseconds) taken to return to the default beta position.
  38185. * Negative value indicates camera should not return to default.
  38186. */
  38187. set elevationReturnTime(speed: number);
  38188. /**
  38189. * Gets the time (in milliseconds) taken to return to the default beta position.
  38190. * Negative value indicates camera should not return to default.
  38191. */
  38192. get elevationReturnTime(): number;
  38193. /**
  38194. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38195. */
  38196. set elevationReturnWaitTime(time: number);
  38197. /**
  38198. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38199. */
  38200. get elevationReturnWaitTime(): number;
  38201. /**
  38202. * Sets the flag that indicates if user zooming should stop animation.
  38203. */
  38204. set zoomStopsAnimation(flag: boolean);
  38205. /**
  38206. * Gets the flag that indicates if user zooming should stop animation.
  38207. */
  38208. get zoomStopsAnimation(): boolean;
  38209. /**
  38210. * Sets the transition time when framing the mesh, in milliseconds
  38211. */
  38212. set framingTime(time: number);
  38213. /**
  38214. * Gets the transition time when framing the mesh, in milliseconds
  38215. */
  38216. get framingTime(): number;
  38217. /**
  38218. * Define if the behavior should automatically change the configured
  38219. * camera limits and sensibilities.
  38220. */
  38221. autoCorrectCameraLimitsAndSensibility: boolean;
  38222. private _onPrePointerObservableObserver;
  38223. private _onAfterCheckInputsObserver;
  38224. private _onMeshTargetChangedObserver;
  38225. private _attachedCamera;
  38226. private _isPointerDown;
  38227. private _lastInteractionTime;
  38228. /**
  38229. * Initializes the behavior.
  38230. */
  38231. init(): void;
  38232. /**
  38233. * Attaches the behavior to its arc rotate camera.
  38234. * @param camera Defines the camera to attach the behavior to
  38235. */
  38236. attach(camera: ArcRotateCamera): void;
  38237. /**
  38238. * Detaches the behavior from its current arc rotate camera.
  38239. */
  38240. detach(): void;
  38241. private _animatables;
  38242. private _betaIsAnimating;
  38243. private _betaTransition;
  38244. private _radiusTransition;
  38245. private _vectorTransition;
  38246. /**
  38247. * Targets the given mesh and updates zoom level accordingly.
  38248. * @param mesh The mesh to target.
  38249. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38250. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38251. */
  38252. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38253. /**
  38254. * Targets the given mesh with its children and updates zoom level accordingly.
  38255. * @param mesh The mesh to target.
  38256. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38257. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38258. */
  38259. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38260. /**
  38261. * Targets the given meshes with their children and updates zoom level accordingly.
  38262. * @param meshes The mesh to target.
  38263. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38264. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38265. */
  38266. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38267. /**
  38268. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38269. * @param minimumWorld Determines the smaller position of the bounding box extend
  38270. * @param maximumWorld Determines the bigger position of the bounding box extend
  38271. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38272. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38273. */
  38274. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38275. /**
  38276. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38277. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38278. * frustum width.
  38279. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38280. * to fully enclose the mesh in the viewing frustum.
  38281. */
  38282. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38283. /**
  38284. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38285. * is automatically returned to its default position (expected to be above ground plane).
  38286. */
  38287. private _maintainCameraAboveGround;
  38288. /**
  38289. * Returns the frustum slope based on the canvas ratio and camera FOV
  38290. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38291. */
  38292. private _getFrustumSlope;
  38293. /**
  38294. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38295. */
  38296. private _clearAnimationLocks;
  38297. /**
  38298. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38299. */
  38300. private _applyUserInteraction;
  38301. /**
  38302. * Stops and removes all animations that have been applied to the camera
  38303. */
  38304. stopAllAnimations(): void;
  38305. /**
  38306. * Gets a value indicating if the user is moving the camera
  38307. */
  38308. get isUserIsMoving(): boolean;
  38309. /**
  38310. * The camera can move all the way towards the mesh.
  38311. */
  38312. static IgnoreBoundsSizeMode: number;
  38313. /**
  38314. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38315. */
  38316. static FitFrustumSidesMode: number;
  38317. }
  38318. }
  38319. declare module BABYLON {
  38320. /**
  38321. * Base class for Camera Pointer Inputs.
  38322. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38323. * for example usage.
  38324. */
  38325. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38326. /**
  38327. * Defines the camera the input is attached to.
  38328. */
  38329. abstract camera: Camera;
  38330. /**
  38331. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38332. */
  38333. protected _altKey: boolean;
  38334. protected _ctrlKey: boolean;
  38335. protected _metaKey: boolean;
  38336. protected _shiftKey: boolean;
  38337. /**
  38338. * Which mouse buttons were pressed at time of last mouse event.
  38339. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38340. */
  38341. protected _buttonsPressed: number;
  38342. /**
  38343. * Defines the buttons associated with the input to handle camera move.
  38344. */
  38345. buttons: number[];
  38346. /**
  38347. * Attach the input controls to a specific dom element to get the input from.
  38348. * @param element Defines the element the controls should be listened from
  38349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38350. */
  38351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38352. /**
  38353. * Detach the current controls from the specified dom element.
  38354. * @param element Defines the element to stop listening the inputs from
  38355. */
  38356. detachControl(element: Nullable<HTMLElement>): void;
  38357. /**
  38358. * Gets the class name of the current input.
  38359. * @returns the class name
  38360. */
  38361. getClassName(): string;
  38362. /**
  38363. * Get the friendly name associated with the input class.
  38364. * @returns the input friendly name
  38365. */
  38366. getSimpleName(): string;
  38367. /**
  38368. * Called on pointer POINTERDOUBLETAP event.
  38369. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38370. */
  38371. protected onDoubleTap(type: string): void;
  38372. /**
  38373. * Called on pointer POINTERMOVE event if only a single touch is active.
  38374. * Override this method to provide functionality.
  38375. */
  38376. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38377. /**
  38378. * Called on pointer POINTERMOVE event if multiple touches are active.
  38379. * Override this method to provide functionality.
  38380. */
  38381. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38382. /**
  38383. * Called on JS contextmenu event.
  38384. * Override this method to provide functionality.
  38385. */
  38386. protected onContextMenu(evt: PointerEvent): void;
  38387. /**
  38388. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38389. * press.
  38390. * Override this method to provide functionality.
  38391. */
  38392. protected onButtonDown(evt: PointerEvent): void;
  38393. /**
  38394. * Called each time a new POINTERUP event occurs. Ie, for each button
  38395. * release.
  38396. * Override this method to provide functionality.
  38397. */
  38398. protected onButtonUp(evt: PointerEvent): void;
  38399. /**
  38400. * Called when window becomes inactive.
  38401. * Override this method to provide functionality.
  38402. */
  38403. protected onLostFocus(): void;
  38404. private _pointerInput;
  38405. private _observer;
  38406. private _onLostFocus;
  38407. private pointA;
  38408. private pointB;
  38409. }
  38410. }
  38411. declare module BABYLON {
  38412. /**
  38413. * Manage the pointers inputs to control an arc rotate camera.
  38414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38415. */
  38416. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38417. /**
  38418. * Defines the camera the input is attached to.
  38419. */
  38420. camera: ArcRotateCamera;
  38421. /**
  38422. * Gets the class name of the current input.
  38423. * @returns the class name
  38424. */
  38425. getClassName(): string;
  38426. /**
  38427. * Defines the buttons associated with the input to handle camera move.
  38428. */
  38429. buttons: number[];
  38430. /**
  38431. * Defines the pointer angular sensibility along the X axis or how fast is
  38432. * the camera rotating.
  38433. */
  38434. angularSensibilityX: number;
  38435. /**
  38436. * Defines the pointer angular sensibility along the Y axis or how fast is
  38437. * the camera rotating.
  38438. */
  38439. angularSensibilityY: number;
  38440. /**
  38441. * Defines the pointer pinch precision or how fast is the camera zooming.
  38442. */
  38443. pinchPrecision: number;
  38444. /**
  38445. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38446. * from 0.
  38447. * It defines the percentage of current camera.radius to use as delta when
  38448. * pinch zoom is used.
  38449. */
  38450. pinchDeltaPercentage: number;
  38451. /**
  38452. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38453. * that any object in the plane at the camera's target point will scale
  38454. * perfectly with finger motion.
  38455. * Overrides pinchDeltaPercentage and pinchPrecision.
  38456. */
  38457. useNaturalPinchZoom: boolean;
  38458. /**
  38459. * Defines the pointer panning sensibility or how fast is the camera moving.
  38460. */
  38461. panningSensibility: number;
  38462. /**
  38463. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38464. */
  38465. multiTouchPanning: boolean;
  38466. /**
  38467. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38468. * zoom (pinch) through multitouch.
  38469. */
  38470. multiTouchPanAndZoom: boolean;
  38471. /**
  38472. * Revers pinch action direction.
  38473. */
  38474. pinchInwards: boolean;
  38475. private _isPanClick;
  38476. private _twoFingerActivityCount;
  38477. private _isPinching;
  38478. /**
  38479. * Called on pointer POINTERMOVE event if only a single touch is active.
  38480. */
  38481. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38482. /**
  38483. * Called on pointer POINTERDOUBLETAP event.
  38484. */
  38485. protected onDoubleTap(type: string): void;
  38486. /**
  38487. * Called on pointer POINTERMOVE event if multiple touches are active.
  38488. */
  38489. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38490. /**
  38491. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38492. * press.
  38493. */
  38494. protected onButtonDown(evt: PointerEvent): void;
  38495. /**
  38496. * Called each time a new POINTERUP event occurs. Ie, for each button
  38497. * release.
  38498. */
  38499. protected onButtonUp(evt: PointerEvent): void;
  38500. /**
  38501. * Called when window becomes inactive.
  38502. */
  38503. protected onLostFocus(): void;
  38504. }
  38505. }
  38506. declare module BABYLON {
  38507. /**
  38508. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38510. */
  38511. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38512. /**
  38513. * Defines the camera the input is attached to.
  38514. */
  38515. camera: ArcRotateCamera;
  38516. /**
  38517. * Defines the list of key codes associated with the up action (increase alpha)
  38518. */
  38519. keysUp: number[];
  38520. /**
  38521. * Defines the list of key codes associated with the down action (decrease alpha)
  38522. */
  38523. keysDown: number[];
  38524. /**
  38525. * Defines the list of key codes associated with the left action (increase beta)
  38526. */
  38527. keysLeft: number[];
  38528. /**
  38529. * Defines the list of key codes associated with the right action (decrease beta)
  38530. */
  38531. keysRight: number[];
  38532. /**
  38533. * Defines the list of key codes associated with the reset action.
  38534. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38535. */
  38536. keysReset: number[];
  38537. /**
  38538. * Defines the panning sensibility of the inputs.
  38539. * (How fast is the camera panning)
  38540. */
  38541. panningSensibility: number;
  38542. /**
  38543. * Defines the zooming sensibility of the inputs.
  38544. * (How fast is the camera zooming)
  38545. */
  38546. zoomingSensibility: number;
  38547. /**
  38548. * Defines whether maintaining the alt key down switch the movement mode from
  38549. * orientation to zoom.
  38550. */
  38551. useAltToZoom: boolean;
  38552. /**
  38553. * Rotation speed of the camera
  38554. */
  38555. angularSpeed: number;
  38556. private _keys;
  38557. private _ctrlPressed;
  38558. private _altPressed;
  38559. private _onCanvasBlurObserver;
  38560. private _onKeyboardObserver;
  38561. private _engine;
  38562. private _scene;
  38563. /**
  38564. * Attach the input controls to a specific dom element to get the input from.
  38565. * @param element Defines the element the controls should be listened from
  38566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38567. */
  38568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38569. /**
  38570. * Detach the current controls from the specified dom element.
  38571. * @param element Defines the element to stop listening the inputs from
  38572. */
  38573. detachControl(element: Nullable<HTMLElement>): void;
  38574. /**
  38575. * Update the current camera state depending on the inputs that have been used this frame.
  38576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38577. */
  38578. checkInputs(): void;
  38579. /**
  38580. * Gets the class name of the current intput.
  38581. * @returns the class name
  38582. */
  38583. getClassName(): string;
  38584. /**
  38585. * Get the friendly name associated with the input class.
  38586. * @returns the input friendly name
  38587. */
  38588. getSimpleName(): string;
  38589. }
  38590. }
  38591. declare module BABYLON {
  38592. /**
  38593. * Manage the mouse wheel inputs to control an arc rotate camera.
  38594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38595. */
  38596. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38597. /**
  38598. * Defines the camera the input is attached to.
  38599. */
  38600. camera: ArcRotateCamera;
  38601. /**
  38602. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38603. */
  38604. wheelPrecision: number;
  38605. /**
  38606. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38607. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38608. */
  38609. wheelDeltaPercentage: number;
  38610. private _wheel;
  38611. private _observer;
  38612. private computeDeltaFromMouseWheelLegacyEvent;
  38613. /**
  38614. * Attach the input controls to a specific dom element to get the input from.
  38615. * @param element Defines the element the controls should be listened from
  38616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38617. */
  38618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38619. /**
  38620. * Detach the current controls from the specified dom element.
  38621. * @param element Defines the element to stop listening the inputs from
  38622. */
  38623. detachControl(element: Nullable<HTMLElement>): void;
  38624. /**
  38625. * Gets the class name of the current intput.
  38626. * @returns the class name
  38627. */
  38628. getClassName(): string;
  38629. /**
  38630. * Get the friendly name associated with the input class.
  38631. * @returns the input friendly name
  38632. */
  38633. getSimpleName(): string;
  38634. }
  38635. }
  38636. declare module BABYLON {
  38637. /**
  38638. * Default Inputs manager for the ArcRotateCamera.
  38639. * It groups all the default supported inputs for ease of use.
  38640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38641. */
  38642. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38643. /**
  38644. * Instantiates a new ArcRotateCameraInputsManager.
  38645. * @param camera Defines the camera the inputs belong to
  38646. */
  38647. constructor(camera: ArcRotateCamera);
  38648. /**
  38649. * Add mouse wheel input support to the input manager.
  38650. * @returns the current input manager
  38651. */
  38652. addMouseWheel(): ArcRotateCameraInputsManager;
  38653. /**
  38654. * Add pointers input support to the input manager.
  38655. * @returns the current input manager
  38656. */
  38657. addPointers(): ArcRotateCameraInputsManager;
  38658. /**
  38659. * Add keyboard input support to the input manager.
  38660. * @returns the current input manager
  38661. */
  38662. addKeyboard(): ArcRotateCameraInputsManager;
  38663. }
  38664. }
  38665. declare module BABYLON {
  38666. /**
  38667. * This represents an orbital type of camera.
  38668. *
  38669. * 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.
  38670. * 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.
  38671. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38672. */
  38673. export class ArcRotateCamera extends TargetCamera {
  38674. /**
  38675. * Defines the rotation angle of the camera along the longitudinal axis.
  38676. */
  38677. alpha: number;
  38678. /**
  38679. * Defines the rotation angle of the camera along the latitudinal axis.
  38680. */
  38681. beta: number;
  38682. /**
  38683. * Defines the radius of the camera from it s target point.
  38684. */
  38685. radius: number;
  38686. protected _target: Vector3;
  38687. protected _targetHost: Nullable<AbstractMesh>;
  38688. /**
  38689. * Defines the target point of the camera.
  38690. * The camera looks towards it form the radius distance.
  38691. */
  38692. get target(): Vector3;
  38693. set target(value: Vector3);
  38694. /**
  38695. * Define the current local position of the camera in the scene
  38696. */
  38697. get position(): Vector3;
  38698. set position(newPosition: Vector3);
  38699. protected _upVector: Vector3;
  38700. protected _upToYMatrix: Matrix;
  38701. protected _YToUpMatrix: Matrix;
  38702. /**
  38703. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38704. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38705. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38706. */
  38707. set upVector(vec: Vector3);
  38708. get upVector(): Vector3;
  38709. /**
  38710. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38711. */
  38712. setMatUp(): void;
  38713. /**
  38714. * Current inertia value on the longitudinal axis.
  38715. * The bigger this number the longer it will take for the camera to stop.
  38716. */
  38717. inertialAlphaOffset: number;
  38718. /**
  38719. * Current inertia value on the latitudinal axis.
  38720. * The bigger this number the longer it will take for the camera to stop.
  38721. */
  38722. inertialBetaOffset: number;
  38723. /**
  38724. * Current inertia value on the radius axis.
  38725. * The bigger this number the longer it will take for the camera to stop.
  38726. */
  38727. inertialRadiusOffset: number;
  38728. /**
  38729. * Minimum allowed angle on the longitudinal axis.
  38730. * This can help limiting how the Camera is able to move in the scene.
  38731. */
  38732. lowerAlphaLimit: Nullable<number>;
  38733. /**
  38734. * Maximum allowed angle on the longitudinal axis.
  38735. * This can help limiting how the Camera is able to move in the scene.
  38736. */
  38737. upperAlphaLimit: Nullable<number>;
  38738. /**
  38739. * Minimum allowed angle on the latitudinal axis.
  38740. * This can help limiting how the Camera is able to move in the scene.
  38741. */
  38742. lowerBetaLimit: number;
  38743. /**
  38744. * Maximum allowed angle on the latitudinal axis.
  38745. * This can help limiting how the Camera is able to move in the scene.
  38746. */
  38747. upperBetaLimit: number;
  38748. /**
  38749. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38750. * This can help limiting how the Camera is able to move in the scene.
  38751. */
  38752. lowerRadiusLimit: Nullable<number>;
  38753. /**
  38754. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38755. * This can help limiting how the Camera is able to move in the scene.
  38756. */
  38757. upperRadiusLimit: Nullable<number>;
  38758. /**
  38759. * Defines the current inertia value used during panning of the camera along the X axis.
  38760. */
  38761. inertialPanningX: number;
  38762. /**
  38763. * Defines the current inertia value used during panning of the camera along the Y axis.
  38764. */
  38765. inertialPanningY: number;
  38766. /**
  38767. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38768. * Basically if your fingers moves away from more than this distance you will be considered
  38769. * in pinch mode.
  38770. */
  38771. pinchToPanMaxDistance: number;
  38772. /**
  38773. * Defines the maximum distance the camera can pan.
  38774. * This could help keeping the cammera always in your scene.
  38775. */
  38776. panningDistanceLimit: Nullable<number>;
  38777. /**
  38778. * Defines the target of the camera before paning.
  38779. */
  38780. panningOriginTarget: Vector3;
  38781. /**
  38782. * Defines the value of the inertia used during panning.
  38783. * 0 would mean stop inertia and one would mean no decelleration at all.
  38784. */
  38785. panningInertia: number;
  38786. /**
  38787. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38788. */
  38789. get angularSensibilityX(): number;
  38790. set angularSensibilityX(value: number);
  38791. /**
  38792. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38793. */
  38794. get angularSensibilityY(): number;
  38795. set angularSensibilityY(value: number);
  38796. /**
  38797. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38798. */
  38799. get pinchPrecision(): number;
  38800. set pinchPrecision(value: number);
  38801. /**
  38802. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38803. * It will be used instead of pinchDeltaPrecision if different from 0.
  38804. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38805. */
  38806. get pinchDeltaPercentage(): number;
  38807. set pinchDeltaPercentage(value: number);
  38808. /**
  38809. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38810. * and pinch delta percentage.
  38811. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38812. * that any object in the plane at the camera's target point will scale
  38813. * perfectly with finger motion.
  38814. */
  38815. get useNaturalPinchZoom(): boolean;
  38816. set useNaturalPinchZoom(value: boolean);
  38817. /**
  38818. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38819. */
  38820. get panningSensibility(): number;
  38821. set panningSensibility(value: number);
  38822. /**
  38823. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38824. */
  38825. get keysUp(): number[];
  38826. set keysUp(value: number[]);
  38827. /**
  38828. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38829. */
  38830. get keysDown(): number[];
  38831. set keysDown(value: number[]);
  38832. /**
  38833. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38834. */
  38835. get keysLeft(): number[];
  38836. set keysLeft(value: number[]);
  38837. /**
  38838. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38839. */
  38840. get keysRight(): number[];
  38841. set keysRight(value: number[]);
  38842. /**
  38843. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38844. */
  38845. get wheelPrecision(): number;
  38846. set wheelPrecision(value: number);
  38847. /**
  38848. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38849. * It will be used instead of pinchDeltaPrecision if different from 0.
  38850. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38851. */
  38852. get wheelDeltaPercentage(): number;
  38853. set wheelDeltaPercentage(value: number);
  38854. /**
  38855. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38856. */
  38857. zoomOnFactor: number;
  38858. /**
  38859. * Defines a screen offset for the camera position.
  38860. */
  38861. targetScreenOffset: Vector2;
  38862. /**
  38863. * Allows the camera to be completely reversed.
  38864. * If false the camera can not arrive upside down.
  38865. */
  38866. allowUpsideDown: boolean;
  38867. /**
  38868. * Define if double tap/click is used to restore the previously saved state of the camera.
  38869. */
  38870. useInputToRestoreState: boolean;
  38871. /** @hidden */
  38872. _viewMatrix: Matrix;
  38873. /** @hidden */
  38874. _useCtrlForPanning: boolean;
  38875. /** @hidden */
  38876. _panningMouseButton: number;
  38877. /**
  38878. * Defines the input associated to the camera.
  38879. */
  38880. inputs: ArcRotateCameraInputsManager;
  38881. /** @hidden */
  38882. _reset: () => void;
  38883. /**
  38884. * Defines the allowed panning axis.
  38885. */
  38886. panningAxis: Vector3;
  38887. protected _localDirection: Vector3;
  38888. protected _transformedDirection: Vector3;
  38889. private _bouncingBehavior;
  38890. /**
  38891. * Gets the bouncing behavior of the camera if it has been enabled.
  38892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38893. */
  38894. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38895. /**
  38896. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38897. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38898. */
  38899. get useBouncingBehavior(): boolean;
  38900. set useBouncingBehavior(value: boolean);
  38901. private _framingBehavior;
  38902. /**
  38903. * Gets the framing behavior of the camera if it has been enabled.
  38904. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38905. */
  38906. get framingBehavior(): Nullable<FramingBehavior>;
  38907. /**
  38908. * Defines if the framing behavior of the camera is enabled on the camera.
  38909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38910. */
  38911. get useFramingBehavior(): boolean;
  38912. set useFramingBehavior(value: boolean);
  38913. private _autoRotationBehavior;
  38914. /**
  38915. * Gets the auto rotation behavior of the camera if it has been enabled.
  38916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38917. */
  38918. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38919. /**
  38920. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38922. */
  38923. get useAutoRotationBehavior(): boolean;
  38924. set useAutoRotationBehavior(value: boolean);
  38925. /**
  38926. * Observable triggered when the mesh target has been changed on the camera.
  38927. */
  38928. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38929. /**
  38930. * Event raised when the camera is colliding with a mesh.
  38931. */
  38932. onCollide: (collidedMesh: AbstractMesh) => void;
  38933. /**
  38934. * Defines whether the camera should check collision with the objects oh the scene.
  38935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38936. */
  38937. checkCollisions: boolean;
  38938. /**
  38939. * Defines the collision radius of the camera.
  38940. * This simulates a sphere around the camera.
  38941. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38942. */
  38943. collisionRadius: Vector3;
  38944. protected _collider: Collider;
  38945. protected _previousPosition: Vector3;
  38946. protected _collisionVelocity: Vector3;
  38947. protected _newPosition: Vector3;
  38948. protected _previousAlpha: number;
  38949. protected _previousBeta: number;
  38950. protected _previousRadius: number;
  38951. protected _collisionTriggered: boolean;
  38952. protected _targetBoundingCenter: Nullable<Vector3>;
  38953. private _computationVector;
  38954. /**
  38955. * Instantiates a new ArcRotateCamera in a given scene
  38956. * @param name Defines the name of the camera
  38957. * @param alpha Defines the camera rotation along the logitudinal axis
  38958. * @param beta Defines the camera rotation along the latitudinal axis
  38959. * @param radius Defines the camera distance from its target
  38960. * @param target Defines the camera target
  38961. * @param scene Defines the scene the camera belongs to
  38962. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38963. */
  38964. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38965. /** @hidden */
  38966. _initCache(): void;
  38967. /** @hidden */
  38968. _updateCache(ignoreParentClass?: boolean): void;
  38969. protected _getTargetPosition(): Vector3;
  38970. private _storedAlpha;
  38971. private _storedBeta;
  38972. private _storedRadius;
  38973. private _storedTarget;
  38974. private _storedTargetScreenOffset;
  38975. /**
  38976. * Stores the current state of the camera (alpha, beta, radius and target)
  38977. * @returns the camera itself
  38978. */
  38979. storeState(): Camera;
  38980. /**
  38981. * @hidden
  38982. * Restored camera state. You must call storeState() first
  38983. */
  38984. _restoreStateValues(): boolean;
  38985. /** @hidden */
  38986. _isSynchronizedViewMatrix(): boolean;
  38987. /**
  38988. * Attached controls to the current camera.
  38989. * @param element Defines the element the controls should be listened from
  38990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38991. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38992. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38993. */
  38994. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38995. /**
  38996. * Detach the current controls from the camera.
  38997. * The camera will stop reacting to inputs.
  38998. * @param element Defines the element to stop listening the inputs from
  38999. */
  39000. detachControl(element: HTMLElement): void;
  39001. /** @hidden */
  39002. _checkInputs(): void;
  39003. protected _checkLimits(): void;
  39004. /**
  39005. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39006. */
  39007. rebuildAnglesAndRadius(): void;
  39008. /**
  39009. * Use a position to define the current camera related information like alpha, beta and radius
  39010. * @param position Defines the position to set the camera at
  39011. */
  39012. setPosition(position: Vector3): void;
  39013. /**
  39014. * Defines the target the camera should look at.
  39015. * This will automatically adapt alpha beta and radius to fit within the new target.
  39016. * @param target Defines the new target as a Vector or a mesh
  39017. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39018. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39019. */
  39020. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39021. /** @hidden */
  39022. _getViewMatrix(): Matrix;
  39023. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39024. /**
  39025. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39026. * @param meshes Defines the mesh to zoom on
  39027. * @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)
  39028. */
  39029. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39030. /**
  39031. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39032. * The target will be changed but the radius
  39033. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39034. * @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)
  39035. */
  39036. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39037. min: Vector3;
  39038. max: Vector3;
  39039. distance: number;
  39040. }, doNotUpdateMaxZ?: boolean): void;
  39041. /**
  39042. * @override
  39043. * Override Camera.createRigCamera
  39044. */
  39045. createRigCamera(name: string, cameraIndex: number): Camera;
  39046. /**
  39047. * @hidden
  39048. * @override
  39049. * Override Camera._updateRigCameras
  39050. */
  39051. _updateRigCameras(): void;
  39052. /**
  39053. * Destroy the camera and release the current resources hold by it.
  39054. */
  39055. dispose(): void;
  39056. /**
  39057. * Gets the current object class name.
  39058. * @return the class name
  39059. */
  39060. getClassName(): string;
  39061. }
  39062. }
  39063. declare module BABYLON {
  39064. /**
  39065. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39066. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39067. */
  39068. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39069. /**
  39070. * Gets the name of the behavior.
  39071. */
  39072. get name(): string;
  39073. private _zoomStopsAnimation;
  39074. private _idleRotationSpeed;
  39075. private _idleRotationWaitTime;
  39076. private _idleRotationSpinupTime;
  39077. /**
  39078. * Sets the flag that indicates if user zooming should stop animation.
  39079. */
  39080. set zoomStopsAnimation(flag: boolean);
  39081. /**
  39082. * Gets the flag that indicates if user zooming should stop animation.
  39083. */
  39084. get zoomStopsAnimation(): boolean;
  39085. /**
  39086. * Sets the default speed at which the camera rotates around the model.
  39087. */
  39088. set idleRotationSpeed(speed: number);
  39089. /**
  39090. * Gets the default speed at which the camera rotates around the model.
  39091. */
  39092. get idleRotationSpeed(): number;
  39093. /**
  39094. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39095. */
  39096. set idleRotationWaitTime(time: number);
  39097. /**
  39098. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39099. */
  39100. get idleRotationWaitTime(): number;
  39101. /**
  39102. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39103. */
  39104. set idleRotationSpinupTime(time: number);
  39105. /**
  39106. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39107. */
  39108. get idleRotationSpinupTime(): number;
  39109. /**
  39110. * Gets a value indicating if the camera is currently rotating because of this behavior
  39111. */
  39112. get rotationInProgress(): boolean;
  39113. private _onPrePointerObservableObserver;
  39114. private _onAfterCheckInputsObserver;
  39115. private _attachedCamera;
  39116. private _isPointerDown;
  39117. private _lastFrameTime;
  39118. private _lastInteractionTime;
  39119. private _cameraRotationSpeed;
  39120. /**
  39121. * Initializes the behavior.
  39122. */
  39123. init(): void;
  39124. /**
  39125. * Attaches the behavior to its arc rotate camera.
  39126. * @param camera Defines the camera to attach the behavior to
  39127. */
  39128. attach(camera: ArcRotateCamera): void;
  39129. /**
  39130. * Detaches the behavior from its current arc rotate camera.
  39131. */
  39132. detach(): void;
  39133. /**
  39134. * Returns true if user is scrolling.
  39135. * @return true if user is scrolling.
  39136. */
  39137. private _userIsZooming;
  39138. private _lastFrameRadius;
  39139. private _shouldAnimationStopForInteraction;
  39140. /**
  39141. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39142. */
  39143. private _applyUserInteraction;
  39144. private _userIsMoving;
  39145. }
  39146. }
  39147. declare module BABYLON {
  39148. /**
  39149. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39150. */
  39151. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39152. private ui;
  39153. /**
  39154. * The name of the behavior
  39155. */
  39156. name: string;
  39157. /**
  39158. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39159. */
  39160. distanceAwayFromFace: number;
  39161. /**
  39162. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39163. */
  39164. distanceAwayFromBottomOfFace: number;
  39165. private _faceVectors;
  39166. private _target;
  39167. private _scene;
  39168. private _onRenderObserver;
  39169. private _tmpMatrix;
  39170. private _tmpVector;
  39171. /**
  39172. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39173. * @param ui The transform node that should be attched to the mesh
  39174. */
  39175. constructor(ui: TransformNode);
  39176. /**
  39177. * Initializes the behavior
  39178. */
  39179. init(): void;
  39180. private _closestFace;
  39181. private _zeroVector;
  39182. private _lookAtTmpMatrix;
  39183. private _lookAtToRef;
  39184. /**
  39185. * Attaches the AttachToBoxBehavior to the passed in mesh
  39186. * @param target The mesh that the specified node will be attached to
  39187. */
  39188. attach(target: Mesh): void;
  39189. /**
  39190. * Detaches the behavior from the mesh
  39191. */
  39192. detach(): void;
  39193. }
  39194. }
  39195. declare module BABYLON {
  39196. /**
  39197. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39198. */
  39199. export class FadeInOutBehavior implements Behavior<Mesh> {
  39200. /**
  39201. * Time in milliseconds to delay before fading in (Default: 0)
  39202. */
  39203. delay: number;
  39204. /**
  39205. * Time in milliseconds for the mesh to fade in (Default: 300)
  39206. */
  39207. fadeInTime: number;
  39208. private _millisecondsPerFrame;
  39209. private _hovered;
  39210. private _hoverValue;
  39211. private _ownerNode;
  39212. /**
  39213. * Instatiates the FadeInOutBehavior
  39214. */
  39215. constructor();
  39216. /**
  39217. * The name of the behavior
  39218. */
  39219. get name(): string;
  39220. /**
  39221. * Initializes the behavior
  39222. */
  39223. init(): void;
  39224. /**
  39225. * Attaches the fade behavior on the passed in mesh
  39226. * @param ownerNode The mesh that will be faded in/out once attached
  39227. */
  39228. attach(ownerNode: Mesh): void;
  39229. /**
  39230. * Detaches the behavior from the mesh
  39231. */
  39232. detach(): void;
  39233. /**
  39234. * Triggers the mesh to begin fading in or out
  39235. * @param value if the object should fade in or out (true to fade in)
  39236. */
  39237. fadeIn(value: boolean): void;
  39238. private _update;
  39239. private _setAllVisibility;
  39240. }
  39241. }
  39242. declare module BABYLON {
  39243. /**
  39244. * Class containing a set of static utilities functions for managing Pivots
  39245. * @hidden
  39246. */
  39247. export class PivotTools {
  39248. private static _PivotCached;
  39249. private static _OldPivotPoint;
  39250. private static _PivotTranslation;
  39251. private static _PivotTmpVector;
  39252. /** @hidden */
  39253. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39254. /** @hidden */
  39255. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39256. }
  39257. }
  39258. declare module BABYLON {
  39259. /**
  39260. * Class containing static functions to help procedurally build meshes
  39261. */
  39262. export class PlaneBuilder {
  39263. /**
  39264. * Creates a plane mesh
  39265. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39266. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39267. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39269. * * 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
  39270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39271. * @param name defines the name of the mesh
  39272. * @param options defines the options used to create the mesh
  39273. * @param scene defines the hosting scene
  39274. * @returns the plane mesh
  39275. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39276. */
  39277. static CreatePlane(name: string, options: {
  39278. size?: number;
  39279. width?: number;
  39280. height?: number;
  39281. sideOrientation?: number;
  39282. frontUVs?: Vector4;
  39283. backUVs?: Vector4;
  39284. updatable?: boolean;
  39285. sourcePlane?: Plane;
  39286. }, scene?: Nullable<Scene>): Mesh;
  39287. }
  39288. }
  39289. declare module BABYLON {
  39290. /**
  39291. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39292. */
  39293. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39294. private static _AnyMouseID;
  39295. /**
  39296. * Abstract mesh the behavior is set on
  39297. */
  39298. attachedNode: AbstractMesh;
  39299. private _dragPlane;
  39300. private _scene;
  39301. private _pointerObserver;
  39302. private _beforeRenderObserver;
  39303. private static _planeScene;
  39304. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39305. /**
  39306. * 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)
  39307. */
  39308. maxDragAngle: number;
  39309. /**
  39310. * @hidden
  39311. */
  39312. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39313. /**
  39314. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39315. */
  39316. currentDraggingPointerID: number;
  39317. /**
  39318. * The last position where the pointer hit the drag plane in world space
  39319. */
  39320. lastDragPosition: Vector3;
  39321. /**
  39322. * If the behavior is currently in a dragging state
  39323. */
  39324. dragging: boolean;
  39325. /**
  39326. * 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)
  39327. */
  39328. dragDeltaRatio: number;
  39329. /**
  39330. * If the drag plane orientation should be updated during the dragging (Default: true)
  39331. */
  39332. updateDragPlane: boolean;
  39333. private _debugMode;
  39334. private _moving;
  39335. /**
  39336. * Fires each time the attached mesh is dragged with the pointer
  39337. * * delta between last drag position and current drag position in world space
  39338. * * dragDistance along the drag axis
  39339. * * dragPlaneNormal normal of the current drag plane used during the drag
  39340. * * dragPlanePoint in world space where the drag intersects the drag plane
  39341. */
  39342. onDragObservable: Observable<{
  39343. delta: Vector3;
  39344. dragPlanePoint: Vector3;
  39345. dragPlaneNormal: Vector3;
  39346. dragDistance: number;
  39347. pointerId: number;
  39348. }>;
  39349. /**
  39350. * Fires each time a drag begins (eg. mouse down on mesh)
  39351. */
  39352. onDragStartObservable: Observable<{
  39353. dragPlanePoint: Vector3;
  39354. pointerId: number;
  39355. }>;
  39356. /**
  39357. * Fires each time a drag ends (eg. mouse release after drag)
  39358. */
  39359. onDragEndObservable: Observable<{
  39360. dragPlanePoint: Vector3;
  39361. pointerId: number;
  39362. }>;
  39363. /**
  39364. * If the attached mesh should be moved when dragged
  39365. */
  39366. moveAttached: boolean;
  39367. /**
  39368. * If the drag behavior will react to drag events (Default: true)
  39369. */
  39370. enabled: boolean;
  39371. /**
  39372. * If pointer events should start and release the drag (Default: true)
  39373. */
  39374. startAndReleaseDragOnPointerEvents: boolean;
  39375. /**
  39376. * If camera controls should be detached during the drag
  39377. */
  39378. detachCameraControls: boolean;
  39379. /**
  39380. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39381. */
  39382. useObjectOrientationForDragging: boolean;
  39383. private _options;
  39384. /**
  39385. * Gets the options used by the behavior
  39386. */
  39387. get options(): {
  39388. dragAxis?: Vector3;
  39389. dragPlaneNormal?: Vector3;
  39390. };
  39391. /**
  39392. * Sets the options used by the behavior
  39393. */
  39394. set options(options: {
  39395. dragAxis?: Vector3;
  39396. dragPlaneNormal?: Vector3;
  39397. });
  39398. /**
  39399. * Creates a pointer drag behavior that can be attached to a mesh
  39400. * @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)
  39401. */
  39402. constructor(options?: {
  39403. dragAxis?: Vector3;
  39404. dragPlaneNormal?: Vector3;
  39405. });
  39406. /**
  39407. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39408. */
  39409. validateDrag: (targetPosition: Vector3) => boolean;
  39410. /**
  39411. * The name of the behavior
  39412. */
  39413. get name(): string;
  39414. /**
  39415. * Initializes the behavior
  39416. */
  39417. init(): void;
  39418. private _tmpVector;
  39419. private _alternatePickedPoint;
  39420. private _worldDragAxis;
  39421. private _targetPosition;
  39422. private _attachedElement;
  39423. /**
  39424. * Attaches the drag behavior the passed in mesh
  39425. * @param ownerNode The mesh that will be dragged around once attached
  39426. * @param predicate Predicate to use for pick filtering
  39427. */
  39428. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39429. /**
  39430. * Force relase the drag action by code.
  39431. */
  39432. releaseDrag(): void;
  39433. private _startDragRay;
  39434. private _lastPointerRay;
  39435. /**
  39436. * Simulates the start of a pointer drag event on the behavior
  39437. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39438. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39439. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39440. */
  39441. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39442. private _startDrag;
  39443. private _dragDelta;
  39444. private _moveDrag;
  39445. private _pickWithRayOnDragPlane;
  39446. private _pointA;
  39447. private _pointB;
  39448. private _pointC;
  39449. private _lineA;
  39450. private _lineB;
  39451. private _localAxis;
  39452. private _lookAt;
  39453. private _updateDragPlanePosition;
  39454. /**
  39455. * Detaches the behavior from the mesh
  39456. */
  39457. detach(): void;
  39458. }
  39459. }
  39460. declare module BABYLON {
  39461. /**
  39462. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39463. */
  39464. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39465. private _dragBehaviorA;
  39466. private _dragBehaviorB;
  39467. private _startDistance;
  39468. private _initialScale;
  39469. private _targetScale;
  39470. private _ownerNode;
  39471. private _sceneRenderObserver;
  39472. /**
  39473. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39474. */
  39475. constructor();
  39476. /**
  39477. * The name of the behavior
  39478. */
  39479. get name(): string;
  39480. /**
  39481. * Initializes the behavior
  39482. */
  39483. init(): void;
  39484. private _getCurrentDistance;
  39485. /**
  39486. * Attaches the scale behavior the passed in mesh
  39487. * @param ownerNode The mesh that will be scaled around once attached
  39488. */
  39489. attach(ownerNode: Mesh): void;
  39490. /**
  39491. * Detaches the behavior from the mesh
  39492. */
  39493. detach(): void;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * 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
  39499. */
  39500. export class SixDofDragBehavior implements Behavior<Mesh> {
  39501. private static _virtualScene;
  39502. private _ownerNode;
  39503. private _sceneRenderObserver;
  39504. private _scene;
  39505. private _targetPosition;
  39506. private _virtualOriginMesh;
  39507. private _virtualDragMesh;
  39508. private _pointerObserver;
  39509. private _moving;
  39510. private _startingOrientation;
  39511. /**
  39512. * 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)
  39513. */
  39514. private zDragFactor;
  39515. /**
  39516. * If the object should rotate to face the drag origin
  39517. */
  39518. rotateDraggedObject: boolean;
  39519. /**
  39520. * If the behavior is currently in a dragging state
  39521. */
  39522. dragging: boolean;
  39523. /**
  39524. * 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)
  39525. */
  39526. dragDeltaRatio: number;
  39527. /**
  39528. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39529. */
  39530. currentDraggingPointerID: number;
  39531. /**
  39532. * If camera controls should be detached during the drag
  39533. */
  39534. detachCameraControls: boolean;
  39535. /**
  39536. * Fires each time a drag starts
  39537. */
  39538. onDragStartObservable: Observable<{}>;
  39539. /**
  39540. * Fires each time a drag ends (eg. mouse release after drag)
  39541. */
  39542. onDragEndObservable: Observable<{}>;
  39543. /**
  39544. * 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
  39545. */
  39546. constructor();
  39547. /**
  39548. * The name of the behavior
  39549. */
  39550. get name(): string;
  39551. /**
  39552. * Initializes the behavior
  39553. */
  39554. init(): void;
  39555. /**
  39556. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39557. */
  39558. private get _pointerCamera();
  39559. /**
  39560. * Attaches the scale behavior the passed in mesh
  39561. * @param ownerNode The mesh that will be scaled around once attached
  39562. */
  39563. attach(ownerNode: Mesh): void;
  39564. /**
  39565. * Detaches the behavior from the mesh
  39566. */
  39567. detach(): void;
  39568. }
  39569. }
  39570. declare module BABYLON {
  39571. /**
  39572. * Class used to apply inverse kinematics to bones
  39573. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39574. */
  39575. export class BoneIKController {
  39576. private static _tmpVecs;
  39577. private static _tmpQuat;
  39578. private static _tmpMats;
  39579. /**
  39580. * Gets or sets the target mesh
  39581. */
  39582. targetMesh: AbstractMesh;
  39583. /** Gets or sets the mesh used as pole */
  39584. poleTargetMesh: AbstractMesh;
  39585. /**
  39586. * Gets or sets the bone used as pole
  39587. */
  39588. poleTargetBone: Nullable<Bone>;
  39589. /**
  39590. * Gets or sets the target position
  39591. */
  39592. targetPosition: Vector3;
  39593. /**
  39594. * Gets or sets the pole target position
  39595. */
  39596. poleTargetPosition: Vector3;
  39597. /**
  39598. * Gets or sets the pole target local offset
  39599. */
  39600. poleTargetLocalOffset: Vector3;
  39601. /**
  39602. * Gets or sets the pole angle
  39603. */
  39604. poleAngle: number;
  39605. /**
  39606. * Gets or sets the mesh associated with the controller
  39607. */
  39608. mesh: AbstractMesh;
  39609. /**
  39610. * 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)
  39611. */
  39612. slerpAmount: number;
  39613. private _bone1Quat;
  39614. private _bone1Mat;
  39615. private _bone2Ang;
  39616. private _bone1;
  39617. private _bone2;
  39618. private _bone1Length;
  39619. private _bone2Length;
  39620. private _maxAngle;
  39621. private _maxReach;
  39622. private _rightHandedSystem;
  39623. private _bendAxis;
  39624. private _slerping;
  39625. private _adjustRoll;
  39626. /**
  39627. * Gets or sets maximum allowed angle
  39628. */
  39629. get maxAngle(): number;
  39630. set maxAngle(value: number);
  39631. /**
  39632. * Creates a new BoneIKController
  39633. * @param mesh defines the mesh to control
  39634. * @param bone defines the bone to control
  39635. * @param options defines options to set up the controller
  39636. */
  39637. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39638. targetMesh?: AbstractMesh;
  39639. poleTargetMesh?: AbstractMesh;
  39640. poleTargetBone?: Bone;
  39641. poleTargetLocalOffset?: Vector3;
  39642. poleAngle?: number;
  39643. bendAxis?: Vector3;
  39644. maxAngle?: number;
  39645. slerpAmount?: number;
  39646. });
  39647. private _setMaxAngle;
  39648. /**
  39649. * Force the controller to update the bones
  39650. */
  39651. update(): void;
  39652. }
  39653. }
  39654. declare module BABYLON {
  39655. /**
  39656. * Class used to make a bone look toward a point in space
  39657. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39658. */
  39659. export class BoneLookController {
  39660. private static _tmpVecs;
  39661. private static _tmpQuat;
  39662. private static _tmpMats;
  39663. /**
  39664. * The target Vector3 that the bone will look at
  39665. */
  39666. target: Vector3;
  39667. /**
  39668. * The mesh that the bone is attached to
  39669. */
  39670. mesh: AbstractMesh;
  39671. /**
  39672. * The bone that will be looking to the target
  39673. */
  39674. bone: Bone;
  39675. /**
  39676. * The up axis of the coordinate system that is used when the bone is rotated
  39677. */
  39678. upAxis: Vector3;
  39679. /**
  39680. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39681. */
  39682. upAxisSpace: Space;
  39683. /**
  39684. * Used to make an adjustment to the yaw of the bone
  39685. */
  39686. adjustYaw: number;
  39687. /**
  39688. * Used to make an adjustment to the pitch of the bone
  39689. */
  39690. adjustPitch: number;
  39691. /**
  39692. * Used to make an adjustment to the roll of the bone
  39693. */
  39694. adjustRoll: number;
  39695. /**
  39696. * 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)
  39697. */
  39698. slerpAmount: number;
  39699. private _minYaw;
  39700. private _maxYaw;
  39701. private _minPitch;
  39702. private _maxPitch;
  39703. private _minYawSin;
  39704. private _minYawCos;
  39705. private _maxYawSin;
  39706. private _maxYawCos;
  39707. private _midYawConstraint;
  39708. private _minPitchTan;
  39709. private _maxPitchTan;
  39710. private _boneQuat;
  39711. private _slerping;
  39712. private _transformYawPitch;
  39713. private _transformYawPitchInv;
  39714. private _firstFrameSkipped;
  39715. private _yawRange;
  39716. private _fowardAxis;
  39717. /**
  39718. * Gets or sets the minimum yaw angle that the bone can look to
  39719. */
  39720. get minYaw(): number;
  39721. set minYaw(value: number);
  39722. /**
  39723. * Gets or sets the maximum yaw angle that the bone can look to
  39724. */
  39725. get maxYaw(): number;
  39726. set maxYaw(value: number);
  39727. /**
  39728. * Gets or sets the minimum pitch angle that the bone can look to
  39729. */
  39730. get minPitch(): number;
  39731. set minPitch(value: number);
  39732. /**
  39733. * Gets or sets the maximum pitch angle that the bone can look to
  39734. */
  39735. get maxPitch(): number;
  39736. set maxPitch(value: number);
  39737. /**
  39738. * Create a BoneLookController
  39739. * @param mesh the mesh that the bone belongs to
  39740. * @param bone the bone that will be looking to the target
  39741. * @param target the target Vector3 to look at
  39742. * @param options optional settings:
  39743. * * maxYaw: the maximum angle the bone will yaw to
  39744. * * minYaw: the minimum angle the bone will yaw to
  39745. * * maxPitch: the maximum angle the bone will pitch to
  39746. * * minPitch: the minimum angle the bone will yaw to
  39747. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39748. * * upAxis: the up axis of the coordinate system
  39749. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39750. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39751. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39752. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39753. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39754. * * adjustRoll: used to make an adjustment to the roll of the bone
  39755. **/
  39756. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39757. maxYaw?: number;
  39758. minYaw?: number;
  39759. maxPitch?: number;
  39760. minPitch?: number;
  39761. slerpAmount?: number;
  39762. upAxis?: Vector3;
  39763. upAxisSpace?: Space;
  39764. yawAxis?: Vector3;
  39765. pitchAxis?: Vector3;
  39766. adjustYaw?: number;
  39767. adjustPitch?: number;
  39768. adjustRoll?: number;
  39769. });
  39770. /**
  39771. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39772. */
  39773. update(): void;
  39774. private _getAngleDiff;
  39775. private _getAngleBetween;
  39776. private _isAngleBetween;
  39777. }
  39778. }
  39779. declare module BABYLON {
  39780. /**
  39781. * Manage the gamepad inputs to control an arc rotate camera.
  39782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39783. */
  39784. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39785. /**
  39786. * Defines the camera the input is attached to.
  39787. */
  39788. camera: ArcRotateCamera;
  39789. /**
  39790. * Defines the gamepad the input is gathering event from.
  39791. */
  39792. gamepad: Nullable<Gamepad>;
  39793. /**
  39794. * Defines the gamepad rotation sensiblity.
  39795. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39796. */
  39797. gamepadRotationSensibility: number;
  39798. /**
  39799. * Defines the gamepad move sensiblity.
  39800. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39801. */
  39802. gamepadMoveSensibility: number;
  39803. private _yAxisScale;
  39804. /**
  39805. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39806. */
  39807. get invertYAxis(): boolean;
  39808. set invertYAxis(value: boolean);
  39809. private _onGamepadConnectedObserver;
  39810. private _onGamepadDisconnectedObserver;
  39811. /**
  39812. * Attach the input controls to a specific dom element to get the input from.
  39813. * @param element Defines the element the controls should be listened from
  39814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39815. */
  39816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39817. /**
  39818. * Detach the current controls from the specified dom element.
  39819. * @param element Defines the element to stop listening the inputs from
  39820. */
  39821. detachControl(element: Nullable<HTMLElement>): void;
  39822. /**
  39823. * Update the current camera state depending on the inputs that have been used this frame.
  39824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39825. */
  39826. checkInputs(): void;
  39827. /**
  39828. * Gets the class name of the current intput.
  39829. * @returns the class name
  39830. */
  39831. getClassName(): string;
  39832. /**
  39833. * Get the friendly name associated with the input class.
  39834. * @returns the input friendly name
  39835. */
  39836. getSimpleName(): string;
  39837. }
  39838. }
  39839. declare module BABYLON {
  39840. interface ArcRotateCameraInputsManager {
  39841. /**
  39842. * Add orientation input support to the input manager.
  39843. * @returns the current input manager
  39844. */
  39845. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39846. }
  39847. /**
  39848. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39850. */
  39851. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39852. /**
  39853. * Defines the camera the input is attached to.
  39854. */
  39855. camera: ArcRotateCamera;
  39856. /**
  39857. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39858. */
  39859. alphaCorrection: number;
  39860. /**
  39861. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39862. */
  39863. gammaCorrection: number;
  39864. private _alpha;
  39865. private _gamma;
  39866. private _dirty;
  39867. private _deviceOrientationHandler;
  39868. /**
  39869. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39870. */
  39871. constructor();
  39872. /**
  39873. * Attach the input controls to a specific dom element to get the input from.
  39874. * @param element Defines the element the controls should be listened from
  39875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39876. */
  39877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39878. /** @hidden */
  39879. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39880. /**
  39881. * Update the current camera state depending on the inputs that have been used this frame.
  39882. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39883. */
  39884. checkInputs(): void;
  39885. /**
  39886. * Detach the current controls from the specified dom element.
  39887. * @param element Defines the element to stop listening the inputs from
  39888. */
  39889. detachControl(element: Nullable<HTMLElement>): void;
  39890. /**
  39891. * Gets the class name of the current intput.
  39892. * @returns the class name
  39893. */
  39894. getClassName(): string;
  39895. /**
  39896. * Get the friendly name associated with the input class.
  39897. * @returns the input friendly name
  39898. */
  39899. getSimpleName(): string;
  39900. }
  39901. }
  39902. declare module BABYLON {
  39903. /**
  39904. * Listen to mouse events to control the camera.
  39905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39906. */
  39907. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39908. /**
  39909. * Defines the camera the input is attached to.
  39910. */
  39911. camera: FlyCamera;
  39912. /**
  39913. * Defines if touch is enabled. (Default is true.)
  39914. */
  39915. touchEnabled: boolean;
  39916. /**
  39917. * Defines the buttons associated with the input to handle camera rotation.
  39918. */
  39919. buttons: number[];
  39920. /**
  39921. * Assign buttons for Yaw control.
  39922. */
  39923. buttonsYaw: number[];
  39924. /**
  39925. * Assign buttons for Pitch control.
  39926. */
  39927. buttonsPitch: number[];
  39928. /**
  39929. * Assign buttons for Roll control.
  39930. */
  39931. buttonsRoll: number[];
  39932. /**
  39933. * Detect if any button is being pressed while mouse is moved.
  39934. * -1 = Mouse locked.
  39935. * 0 = Left button.
  39936. * 1 = Middle Button.
  39937. * 2 = Right Button.
  39938. */
  39939. activeButton: number;
  39940. /**
  39941. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39942. * Higher values reduce its sensitivity.
  39943. */
  39944. angularSensibility: number;
  39945. private _mousemoveCallback;
  39946. private _observer;
  39947. private _rollObserver;
  39948. private previousPosition;
  39949. private noPreventDefault;
  39950. private element;
  39951. /**
  39952. * Listen to mouse events to control the camera.
  39953. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39955. */
  39956. constructor(touchEnabled?: boolean);
  39957. /**
  39958. * Attach the mouse control to the HTML DOM element.
  39959. * @param element Defines the element that listens to the input events.
  39960. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39961. */
  39962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39963. /**
  39964. * Detach the current controls from the specified dom element.
  39965. * @param element Defines the element to stop listening the inputs from
  39966. */
  39967. detachControl(element: Nullable<HTMLElement>): void;
  39968. /**
  39969. * Gets the class name of the current input.
  39970. * @returns the class name.
  39971. */
  39972. getClassName(): string;
  39973. /**
  39974. * Get the friendly name associated with the input class.
  39975. * @returns the input's friendly name.
  39976. */
  39977. getSimpleName(): string;
  39978. private _pointerInput;
  39979. private _onMouseMove;
  39980. /**
  39981. * Rotate camera by mouse offset.
  39982. */
  39983. private rotateCamera;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /**
  39988. * Default Inputs manager for the FlyCamera.
  39989. * It groups all the default supported inputs for ease of use.
  39990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39991. */
  39992. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39993. /**
  39994. * Instantiates a new FlyCameraInputsManager.
  39995. * @param camera Defines the camera the inputs belong to.
  39996. */
  39997. constructor(camera: FlyCamera);
  39998. /**
  39999. * Add keyboard input support to the input manager.
  40000. * @returns the new FlyCameraKeyboardMoveInput().
  40001. */
  40002. addKeyboard(): FlyCameraInputsManager;
  40003. /**
  40004. * Add mouse input support to the input manager.
  40005. * @param touchEnabled Enable touch screen support.
  40006. * @returns the new FlyCameraMouseInput().
  40007. */
  40008. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40009. }
  40010. }
  40011. declare module BABYLON {
  40012. /**
  40013. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40014. * such as in a 3D Space Shooter or a Flight Simulator.
  40015. */
  40016. export class FlyCamera extends TargetCamera {
  40017. /**
  40018. * Define the collision ellipsoid of the camera.
  40019. * This is helpful for simulating a camera body, like a player's body.
  40020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40021. */
  40022. ellipsoid: Vector3;
  40023. /**
  40024. * Define an offset for the position of the ellipsoid around the camera.
  40025. * This can be helpful if the camera is attached away from the player's body center,
  40026. * such as at its head.
  40027. */
  40028. ellipsoidOffset: Vector3;
  40029. /**
  40030. * Enable or disable collisions of the camera with the rest of the scene objects.
  40031. */
  40032. checkCollisions: boolean;
  40033. /**
  40034. * Enable or disable gravity on the camera.
  40035. */
  40036. applyGravity: boolean;
  40037. /**
  40038. * Define the current direction the camera is moving to.
  40039. */
  40040. cameraDirection: Vector3;
  40041. /**
  40042. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40043. * This overrides and empties cameraRotation.
  40044. */
  40045. rotationQuaternion: Quaternion;
  40046. /**
  40047. * Track Roll to maintain the wanted Rolling when looking around.
  40048. */
  40049. _trackRoll: number;
  40050. /**
  40051. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40052. */
  40053. rollCorrect: number;
  40054. /**
  40055. * Mimic a banked turn, Rolling the camera when Yawing.
  40056. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40057. */
  40058. bankedTurn: boolean;
  40059. /**
  40060. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40061. */
  40062. bankedTurnLimit: number;
  40063. /**
  40064. * Value of 0 disables the banked Roll.
  40065. * Value of 1 is equal to the Yaw angle in radians.
  40066. */
  40067. bankedTurnMultiplier: number;
  40068. /**
  40069. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40070. */
  40071. inputs: FlyCameraInputsManager;
  40072. /**
  40073. * Gets the input sensibility for mouse input.
  40074. * Higher values reduce sensitivity.
  40075. */
  40076. get angularSensibility(): number;
  40077. /**
  40078. * Sets the input sensibility for a mouse input.
  40079. * Higher values reduce sensitivity.
  40080. */
  40081. set angularSensibility(value: number);
  40082. /**
  40083. * Get the keys for camera movement forward.
  40084. */
  40085. get keysForward(): number[];
  40086. /**
  40087. * Set the keys for camera movement forward.
  40088. */
  40089. set keysForward(value: number[]);
  40090. /**
  40091. * Get the keys for camera movement backward.
  40092. */
  40093. get keysBackward(): number[];
  40094. set keysBackward(value: number[]);
  40095. /**
  40096. * Get the keys for camera movement up.
  40097. */
  40098. get keysUp(): number[];
  40099. /**
  40100. * Set the keys for camera movement up.
  40101. */
  40102. set keysUp(value: number[]);
  40103. /**
  40104. * Get the keys for camera movement down.
  40105. */
  40106. get keysDown(): number[];
  40107. /**
  40108. * Set the keys for camera movement down.
  40109. */
  40110. set keysDown(value: number[]);
  40111. /**
  40112. * Get the keys for camera movement left.
  40113. */
  40114. get keysLeft(): number[];
  40115. /**
  40116. * Set the keys for camera movement left.
  40117. */
  40118. set keysLeft(value: number[]);
  40119. /**
  40120. * Set the keys for camera movement right.
  40121. */
  40122. get keysRight(): number[];
  40123. /**
  40124. * Set the keys for camera movement right.
  40125. */
  40126. set keysRight(value: number[]);
  40127. /**
  40128. * Event raised when the camera collides with a mesh in the scene.
  40129. */
  40130. onCollide: (collidedMesh: AbstractMesh) => void;
  40131. private _collider;
  40132. private _needMoveForGravity;
  40133. private _oldPosition;
  40134. private _diffPosition;
  40135. private _newPosition;
  40136. /** @hidden */
  40137. _localDirection: Vector3;
  40138. /** @hidden */
  40139. _transformedDirection: Vector3;
  40140. /**
  40141. * Instantiates a FlyCamera.
  40142. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40143. * such as in a 3D Space Shooter or a Flight Simulator.
  40144. * @param name Define the name of the camera in the scene.
  40145. * @param position Define the starting position of the camera in the scene.
  40146. * @param scene Define the scene the camera belongs to.
  40147. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40148. */
  40149. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40150. /**
  40151. * Attach a control to the HTML DOM element.
  40152. * @param element Defines the element that listens to the input events.
  40153. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40154. */
  40155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40156. /**
  40157. * Detach a control from the HTML DOM element.
  40158. * The camera will stop reacting to that input.
  40159. * @param element Defines the element that listens to the input events.
  40160. */
  40161. detachControl(element: HTMLElement): void;
  40162. private _collisionMask;
  40163. /**
  40164. * Get the mask that the camera ignores in collision events.
  40165. */
  40166. get collisionMask(): number;
  40167. /**
  40168. * Set the mask that the camera ignores in collision events.
  40169. */
  40170. set collisionMask(mask: number);
  40171. /** @hidden */
  40172. _collideWithWorld(displacement: Vector3): void;
  40173. /** @hidden */
  40174. private _onCollisionPositionChange;
  40175. /** @hidden */
  40176. _checkInputs(): void;
  40177. /** @hidden */
  40178. _decideIfNeedsToMove(): boolean;
  40179. /** @hidden */
  40180. _updatePosition(): void;
  40181. /**
  40182. * Restore the Roll to its target value at the rate specified.
  40183. * @param rate - Higher means slower restoring.
  40184. * @hidden
  40185. */
  40186. restoreRoll(rate: number): void;
  40187. /**
  40188. * Destroy the camera and release the current resources held by it.
  40189. */
  40190. dispose(): void;
  40191. /**
  40192. * Get the current object class name.
  40193. * @returns the class name.
  40194. */
  40195. getClassName(): string;
  40196. }
  40197. }
  40198. declare module BABYLON {
  40199. /**
  40200. * Listen to keyboard events to control the camera.
  40201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40202. */
  40203. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40204. /**
  40205. * Defines the camera the input is attached to.
  40206. */
  40207. camera: FlyCamera;
  40208. /**
  40209. * The list of keyboard keys used to control the forward move of the camera.
  40210. */
  40211. keysForward: number[];
  40212. /**
  40213. * The list of keyboard keys used to control the backward move of the camera.
  40214. */
  40215. keysBackward: number[];
  40216. /**
  40217. * The list of keyboard keys used to control the forward move of the camera.
  40218. */
  40219. keysUp: number[];
  40220. /**
  40221. * The list of keyboard keys used to control the backward move of the camera.
  40222. */
  40223. keysDown: number[];
  40224. /**
  40225. * The list of keyboard keys used to control the right strafe move of the camera.
  40226. */
  40227. keysRight: number[];
  40228. /**
  40229. * The list of keyboard keys used to control the left strafe move of the camera.
  40230. */
  40231. keysLeft: number[];
  40232. private _keys;
  40233. private _onCanvasBlurObserver;
  40234. private _onKeyboardObserver;
  40235. private _engine;
  40236. private _scene;
  40237. /**
  40238. * Attach the input controls to a specific dom element to get the input from.
  40239. * @param element Defines the element the controls should be listened from
  40240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40241. */
  40242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40243. /**
  40244. * Detach the current controls from the specified dom element.
  40245. * @param element Defines the element to stop listening the inputs from
  40246. */
  40247. detachControl(element: Nullable<HTMLElement>): void;
  40248. /**
  40249. * Gets the class name of the current intput.
  40250. * @returns the class name
  40251. */
  40252. getClassName(): string;
  40253. /** @hidden */
  40254. _onLostFocus(e: FocusEvent): void;
  40255. /**
  40256. * Get the friendly name associated with the input class.
  40257. * @returns the input friendly name
  40258. */
  40259. getSimpleName(): string;
  40260. /**
  40261. * Update the current camera state depending on the inputs that have been used this frame.
  40262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40263. */
  40264. checkInputs(): void;
  40265. }
  40266. }
  40267. declare module BABYLON {
  40268. /**
  40269. * Manage the mouse wheel inputs to control a follow camera.
  40270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40271. */
  40272. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40273. /**
  40274. * Defines the camera the input is attached to.
  40275. */
  40276. camera: FollowCamera;
  40277. /**
  40278. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40279. */
  40280. axisControlRadius: boolean;
  40281. /**
  40282. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40283. */
  40284. axisControlHeight: boolean;
  40285. /**
  40286. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40287. */
  40288. axisControlRotation: boolean;
  40289. /**
  40290. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40291. * relation to mouseWheel events.
  40292. */
  40293. wheelPrecision: number;
  40294. /**
  40295. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40296. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40297. */
  40298. wheelDeltaPercentage: number;
  40299. private _wheel;
  40300. private _observer;
  40301. /**
  40302. * Attach the input controls to a specific dom element to get the input from.
  40303. * @param element Defines the element the controls should be listened from
  40304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40305. */
  40306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40307. /**
  40308. * Detach the current controls from the specified dom element.
  40309. * @param element Defines the element to stop listening the inputs from
  40310. */
  40311. detachControl(element: Nullable<HTMLElement>): void;
  40312. /**
  40313. * Gets the class name of the current intput.
  40314. * @returns the class name
  40315. */
  40316. getClassName(): string;
  40317. /**
  40318. * Get the friendly name associated with the input class.
  40319. * @returns the input friendly name
  40320. */
  40321. getSimpleName(): string;
  40322. }
  40323. }
  40324. declare module BABYLON {
  40325. /**
  40326. * Manage the pointers inputs to control an follow camera.
  40327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40328. */
  40329. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40330. /**
  40331. * Defines the camera the input is attached to.
  40332. */
  40333. camera: FollowCamera;
  40334. /**
  40335. * Gets the class name of the current input.
  40336. * @returns the class name
  40337. */
  40338. getClassName(): string;
  40339. /**
  40340. * Defines the pointer angular sensibility along the X axis or how fast is
  40341. * the camera rotating.
  40342. * A negative number will reverse the axis direction.
  40343. */
  40344. angularSensibilityX: number;
  40345. /**
  40346. * Defines the pointer angular sensibility along the Y axis or how fast is
  40347. * the camera rotating.
  40348. * A negative number will reverse the axis direction.
  40349. */
  40350. angularSensibilityY: number;
  40351. /**
  40352. * Defines the pointer pinch precision or how fast is the camera zooming.
  40353. * A negative number will reverse the axis direction.
  40354. */
  40355. pinchPrecision: number;
  40356. /**
  40357. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40358. * from 0.
  40359. * It defines the percentage of current camera.radius to use as delta when
  40360. * pinch zoom is used.
  40361. */
  40362. pinchDeltaPercentage: number;
  40363. /**
  40364. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40365. */
  40366. axisXControlRadius: boolean;
  40367. /**
  40368. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40369. */
  40370. axisXControlHeight: boolean;
  40371. /**
  40372. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40373. */
  40374. axisXControlRotation: boolean;
  40375. /**
  40376. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40377. */
  40378. axisYControlRadius: boolean;
  40379. /**
  40380. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40381. */
  40382. axisYControlHeight: boolean;
  40383. /**
  40384. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40385. */
  40386. axisYControlRotation: boolean;
  40387. /**
  40388. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40389. */
  40390. axisPinchControlRadius: boolean;
  40391. /**
  40392. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40393. */
  40394. axisPinchControlHeight: boolean;
  40395. /**
  40396. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40397. */
  40398. axisPinchControlRotation: boolean;
  40399. /**
  40400. * Log error messages if basic misconfiguration has occurred.
  40401. */
  40402. warningEnable: boolean;
  40403. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40404. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40405. private _warningCounter;
  40406. private _warning;
  40407. }
  40408. }
  40409. declare module BABYLON {
  40410. /**
  40411. * Default Inputs manager for the FollowCamera.
  40412. * It groups all the default supported inputs for ease of use.
  40413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40414. */
  40415. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40416. /**
  40417. * Instantiates a new FollowCameraInputsManager.
  40418. * @param camera Defines the camera the inputs belong to
  40419. */
  40420. constructor(camera: FollowCamera);
  40421. /**
  40422. * Add keyboard input support to the input manager.
  40423. * @returns the current input manager
  40424. */
  40425. addKeyboard(): FollowCameraInputsManager;
  40426. /**
  40427. * Add mouse wheel input support to the input manager.
  40428. * @returns the current input manager
  40429. */
  40430. addMouseWheel(): FollowCameraInputsManager;
  40431. /**
  40432. * Add pointers input support to the input manager.
  40433. * @returns the current input manager
  40434. */
  40435. addPointers(): FollowCameraInputsManager;
  40436. /**
  40437. * Add orientation input support to the input manager.
  40438. * @returns the current input manager
  40439. */
  40440. addVRDeviceOrientation(): FollowCameraInputsManager;
  40441. }
  40442. }
  40443. declare module BABYLON {
  40444. /**
  40445. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40446. * an arc rotate version arcFollowCamera are available.
  40447. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40448. */
  40449. export class FollowCamera extends TargetCamera {
  40450. /**
  40451. * Distance the follow camera should follow an object at
  40452. */
  40453. radius: number;
  40454. /**
  40455. * Minimum allowed distance of the camera to the axis of rotation
  40456. * (The camera can not get closer).
  40457. * This can help limiting how the Camera is able to move in the scene.
  40458. */
  40459. lowerRadiusLimit: Nullable<number>;
  40460. /**
  40461. * Maximum allowed distance of the camera to the axis of rotation
  40462. * (The camera can not get further).
  40463. * This can help limiting how the Camera is able to move in the scene.
  40464. */
  40465. upperRadiusLimit: Nullable<number>;
  40466. /**
  40467. * Define a rotation offset between the camera and the object it follows
  40468. */
  40469. rotationOffset: number;
  40470. /**
  40471. * Minimum allowed angle to camera position relative to target object.
  40472. * This can help limiting how the Camera is able to move in the scene.
  40473. */
  40474. lowerRotationOffsetLimit: Nullable<number>;
  40475. /**
  40476. * Maximum allowed angle to camera position relative to target object.
  40477. * This can help limiting how the Camera is able to move in the scene.
  40478. */
  40479. upperRotationOffsetLimit: Nullable<number>;
  40480. /**
  40481. * Define a height offset between the camera and the object it follows.
  40482. * It can help following an object from the top (like a car chaing a plane)
  40483. */
  40484. heightOffset: number;
  40485. /**
  40486. * Minimum allowed height of camera position relative to target object.
  40487. * This can help limiting how the Camera is able to move in the scene.
  40488. */
  40489. lowerHeightOffsetLimit: Nullable<number>;
  40490. /**
  40491. * Maximum allowed height of camera position relative to target object.
  40492. * This can help limiting how the Camera is able to move in the scene.
  40493. */
  40494. upperHeightOffsetLimit: Nullable<number>;
  40495. /**
  40496. * Define how fast the camera can accelerate to follow it s target.
  40497. */
  40498. cameraAcceleration: number;
  40499. /**
  40500. * Define the speed limit of the camera following an object.
  40501. */
  40502. maxCameraSpeed: number;
  40503. /**
  40504. * Define the target of the camera.
  40505. */
  40506. lockedTarget: Nullable<AbstractMesh>;
  40507. /**
  40508. * Defines the input associated with the camera.
  40509. */
  40510. inputs: FollowCameraInputsManager;
  40511. /**
  40512. * Instantiates the follow camera.
  40513. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40514. * @param name Define the name of the camera in the scene
  40515. * @param position Define the position of the camera
  40516. * @param scene Define the scene the camera belong to
  40517. * @param lockedTarget Define the target of the camera
  40518. */
  40519. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40520. private _follow;
  40521. /**
  40522. * Attached controls to the current camera.
  40523. * @param element Defines the element the controls should be listened from
  40524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40525. */
  40526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40527. /**
  40528. * Detach the current controls from the camera.
  40529. * The camera will stop reacting to inputs.
  40530. * @param element Defines the element to stop listening the inputs from
  40531. */
  40532. detachControl(element: HTMLElement): void;
  40533. /** @hidden */
  40534. _checkInputs(): void;
  40535. private _checkLimits;
  40536. /**
  40537. * Gets the camera class name.
  40538. * @returns the class name
  40539. */
  40540. getClassName(): string;
  40541. }
  40542. /**
  40543. * Arc Rotate version of the follow camera.
  40544. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40545. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40546. */
  40547. export class ArcFollowCamera extends TargetCamera {
  40548. /** The longitudinal angle of the camera */
  40549. alpha: number;
  40550. /** The latitudinal angle of the camera */
  40551. beta: number;
  40552. /** The radius of the camera from its target */
  40553. radius: number;
  40554. /** Define the camera target (the messh it should follow) */
  40555. target: Nullable<AbstractMesh>;
  40556. private _cartesianCoordinates;
  40557. /**
  40558. * Instantiates a new ArcFollowCamera
  40559. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40560. * @param name Define the name of the camera
  40561. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40562. * @param beta Define the rotation angle of the camera around the elevation axis
  40563. * @param radius Define the radius of the camera from its target point
  40564. * @param target Define the target of the camera
  40565. * @param scene Define the scene the camera belongs to
  40566. */
  40567. constructor(name: string,
  40568. /** The longitudinal angle of the camera */
  40569. alpha: number,
  40570. /** The latitudinal angle of the camera */
  40571. beta: number,
  40572. /** The radius of the camera from its target */
  40573. radius: number,
  40574. /** Define the camera target (the messh it should follow) */
  40575. target: Nullable<AbstractMesh>, scene: Scene);
  40576. private _follow;
  40577. /** @hidden */
  40578. _checkInputs(): void;
  40579. /**
  40580. * Returns the class name of the object.
  40581. * It is mostly used internally for serialization purposes.
  40582. */
  40583. getClassName(): string;
  40584. }
  40585. }
  40586. declare module BABYLON {
  40587. /**
  40588. * Manage the keyboard inputs to control the movement of a follow camera.
  40589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40590. */
  40591. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40592. /**
  40593. * Defines the camera the input is attached to.
  40594. */
  40595. camera: FollowCamera;
  40596. /**
  40597. * Defines the list of key codes associated with the up action (increase heightOffset)
  40598. */
  40599. keysHeightOffsetIncr: number[];
  40600. /**
  40601. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40602. */
  40603. keysHeightOffsetDecr: number[];
  40604. /**
  40605. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40606. */
  40607. keysHeightOffsetModifierAlt: boolean;
  40608. /**
  40609. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40610. */
  40611. keysHeightOffsetModifierCtrl: boolean;
  40612. /**
  40613. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40614. */
  40615. keysHeightOffsetModifierShift: boolean;
  40616. /**
  40617. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40618. */
  40619. keysRotationOffsetIncr: number[];
  40620. /**
  40621. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40622. */
  40623. keysRotationOffsetDecr: number[];
  40624. /**
  40625. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40626. */
  40627. keysRotationOffsetModifierAlt: boolean;
  40628. /**
  40629. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40630. */
  40631. keysRotationOffsetModifierCtrl: boolean;
  40632. /**
  40633. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40634. */
  40635. keysRotationOffsetModifierShift: boolean;
  40636. /**
  40637. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40638. */
  40639. keysRadiusIncr: number[];
  40640. /**
  40641. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40642. */
  40643. keysRadiusDecr: number[];
  40644. /**
  40645. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40646. */
  40647. keysRadiusModifierAlt: boolean;
  40648. /**
  40649. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40650. */
  40651. keysRadiusModifierCtrl: boolean;
  40652. /**
  40653. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40654. */
  40655. keysRadiusModifierShift: boolean;
  40656. /**
  40657. * Defines the rate of change of heightOffset.
  40658. */
  40659. heightSensibility: number;
  40660. /**
  40661. * Defines the rate of change of rotationOffset.
  40662. */
  40663. rotationSensibility: number;
  40664. /**
  40665. * Defines the rate of change of radius.
  40666. */
  40667. radiusSensibility: number;
  40668. private _keys;
  40669. private _ctrlPressed;
  40670. private _altPressed;
  40671. private _shiftPressed;
  40672. private _onCanvasBlurObserver;
  40673. private _onKeyboardObserver;
  40674. private _engine;
  40675. private _scene;
  40676. /**
  40677. * Attach the input controls to a specific dom element to get the input from.
  40678. * @param element Defines the element the controls should be listened from
  40679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40680. */
  40681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40682. /**
  40683. * Detach the current controls from the specified dom element.
  40684. * @param element Defines the element to stop listening the inputs from
  40685. */
  40686. detachControl(element: Nullable<HTMLElement>): void;
  40687. /**
  40688. * Update the current camera state depending on the inputs that have been used this frame.
  40689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40690. */
  40691. checkInputs(): void;
  40692. /**
  40693. * Gets the class name of the current input.
  40694. * @returns the class name
  40695. */
  40696. getClassName(): string;
  40697. /**
  40698. * Get the friendly name associated with the input class.
  40699. * @returns the input friendly name
  40700. */
  40701. getSimpleName(): string;
  40702. /**
  40703. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40704. * allow modification of the heightOffset value.
  40705. */
  40706. private _modifierHeightOffset;
  40707. /**
  40708. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40709. * allow modification of the rotationOffset value.
  40710. */
  40711. private _modifierRotationOffset;
  40712. /**
  40713. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40714. * allow modification of the radius value.
  40715. */
  40716. private _modifierRadius;
  40717. }
  40718. }
  40719. declare module BABYLON {
  40720. interface FreeCameraInputsManager {
  40721. /**
  40722. * @hidden
  40723. */
  40724. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40725. /**
  40726. * Add orientation input support to the input manager.
  40727. * @returns the current input manager
  40728. */
  40729. addDeviceOrientation(): FreeCameraInputsManager;
  40730. }
  40731. /**
  40732. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40733. * Screen rotation is taken into account.
  40734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40735. */
  40736. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40737. private _camera;
  40738. private _screenOrientationAngle;
  40739. private _constantTranform;
  40740. private _screenQuaternion;
  40741. private _alpha;
  40742. private _beta;
  40743. private _gamma;
  40744. /**
  40745. * Can be used to detect if a device orientation sensor is available on a device
  40746. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40747. * @returns a promise that will resolve on orientation change
  40748. */
  40749. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40750. /**
  40751. * @hidden
  40752. */
  40753. _onDeviceOrientationChangedObservable: Observable<void>;
  40754. /**
  40755. * Instantiates a new input
  40756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40757. */
  40758. constructor();
  40759. /**
  40760. * Define the camera controlled by the input.
  40761. */
  40762. get camera(): FreeCamera;
  40763. set camera(camera: FreeCamera);
  40764. /**
  40765. * Attach the input controls to a specific dom element to get the input from.
  40766. * @param element Defines the element the controls should be listened from
  40767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40768. */
  40769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40770. private _orientationChanged;
  40771. private _deviceOrientation;
  40772. /**
  40773. * Detach the current controls from the specified dom element.
  40774. * @param element Defines the element to stop listening the inputs from
  40775. */
  40776. detachControl(element: Nullable<HTMLElement>): void;
  40777. /**
  40778. * Update the current camera state depending on the inputs that have been used this frame.
  40779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40780. */
  40781. checkInputs(): void;
  40782. /**
  40783. * Gets the class name of the current intput.
  40784. * @returns the class name
  40785. */
  40786. getClassName(): string;
  40787. /**
  40788. * Get the friendly name associated with the input class.
  40789. * @returns the input friendly name
  40790. */
  40791. getSimpleName(): string;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. /**
  40796. * Manage the gamepad inputs to control a free camera.
  40797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40798. */
  40799. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40800. /**
  40801. * Define the camera the input is attached to.
  40802. */
  40803. camera: FreeCamera;
  40804. /**
  40805. * Define the Gamepad controlling the input
  40806. */
  40807. gamepad: Nullable<Gamepad>;
  40808. /**
  40809. * Defines the gamepad rotation sensiblity.
  40810. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40811. */
  40812. gamepadAngularSensibility: number;
  40813. /**
  40814. * Defines the gamepad move sensiblity.
  40815. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40816. */
  40817. gamepadMoveSensibility: number;
  40818. private _yAxisScale;
  40819. /**
  40820. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40821. */
  40822. get invertYAxis(): boolean;
  40823. set invertYAxis(value: boolean);
  40824. private _onGamepadConnectedObserver;
  40825. private _onGamepadDisconnectedObserver;
  40826. private _cameraTransform;
  40827. private _deltaTransform;
  40828. private _vector3;
  40829. private _vector2;
  40830. /**
  40831. * Attach the input controls to a specific dom element to get the input from.
  40832. * @param element Defines the element the controls should be listened from
  40833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40834. */
  40835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40836. /**
  40837. * Detach the current controls from the specified dom element.
  40838. * @param element Defines the element to stop listening the inputs from
  40839. */
  40840. detachControl(element: Nullable<HTMLElement>): void;
  40841. /**
  40842. * Update the current camera state depending on the inputs that have been used this frame.
  40843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40844. */
  40845. checkInputs(): void;
  40846. /**
  40847. * Gets the class name of the current intput.
  40848. * @returns the class name
  40849. */
  40850. getClassName(): string;
  40851. /**
  40852. * Get the friendly name associated with the input class.
  40853. * @returns the input friendly name
  40854. */
  40855. getSimpleName(): string;
  40856. }
  40857. }
  40858. declare module BABYLON {
  40859. /**
  40860. * Defines the potential axis of a Joystick
  40861. */
  40862. export enum JoystickAxis {
  40863. /** X axis */
  40864. X = 0,
  40865. /** Y axis */
  40866. Y = 1,
  40867. /** Z axis */
  40868. Z = 2
  40869. }
  40870. /**
  40871. * Class used to define virtual joystick (used in touch mode)
  40872. */
  40873. export class VirtualJoystick {
  40874. /**
  40875. * Gets or sets a boolean indicating that left and right values must be inverted
  40876. */
  40877. reverseLeftRight: boolean;
  40878. /**
  40879. * Gets or sets a boolean indicating that up and down values must be inverted
  40880. */
  40881. reverseUpDown: boolean;
  40882. /**
  40883. * Gets the offset value for the position (ie. the change of the position value)
  40884. */
  40885. deltaPosition: Vector3;
  40886. /**
  40887. * Gets a boolean indicating if the virtual joystick was pressed
  40888. */
  40889. pressed: boolean;
  40890. /**
  40891. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40892. */
  40893. static Canvas: Nullable<HTMLCanvasElement>;
  40894. private static _globalJoystickIndex;
  40895. private static vjCanvasContext;
  40896. private static vjCanvasWidth;
  40897. private static vjCanvasHeight;
  40898. private static halfWidth;
  40899. private _action;
  40900. private _axisTargetedByLeftAndRight;
  40901. private _axisTargetedByUpAndDown;
  40902. private _joystickSensibility;
  40903. private _inversedSensibility;
  40904. private _joystickPointerID;
  40905. private _joystickColor;
  40906. private _joystickPointerPos;
  40907. private _joystickPreviousPointerPos;
  40908. private _joystickPointerStartPos;
  40909. private _deltaJoystickVector;
  40910. private _leftJoystick;
  40911. private _touches;
  40912. private _onPointerDownHandlerRef;
  40913. private _onPointerMoveHandlerRef;
  40914. private _onPointerUpHandlerRef;
  40915. private _onResize;
  40916. /**
  40917. * Creates a new virtual joystick
  40918. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40919. */
  40920. constructor(leftJoystick?: boolean);
  40921. /**
  40922. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40923. * @param newJoystickSensibility defines the new sensibility
  40924. */
  40925. setJoystickSensibility(newJoystickSensibility: number): void;
  40926. private _onPointerDown;
  40927. private _onPointerMove;
  40928. private _onPointerUp;
  40929. /**
  40930. * Change the color of the virtual joystick
  40931. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40932. */
  40933. setJoystickColor(newColor: string): void;
  40934. /**
  40935. * Defines a callback to call when the joystick is touched
  40936. * @param action defines the callback
  40937. */
  40938. setActionOnTouch(action: () => any): void;
  40939. /**
  40940. * Defines which axis you'd like to control for left & right
  40941. * @param axis defines the axis to use
  40942. */
  40943. setAxisForLeftRight(axis: JoystickAxis): void;
  40944. /**
  40945. * Defines which axis you'd like to control for up & down
  40946. * @param axis defines the axis to use
  40947. */
  40948. setAxisForUpDown(axis: JoystickAxis): void;
  40949. private _drawVirtualJoystick;
  40950. /**
  40951. * Release internal HTML canvas
  40952. */
  40953. releaseCanvas(): void;
  40954. }
  40955. }
  40956. declare module BABYLON {
  40957. interface FreeCameraInputsManager {
  40958. /**
  40959. * Add virtual joystick input support to the input manager.
  40960. * @returns the current input manager
  40961. */
  40962. addVirtualJoystick(): FreeCameraInputsManager;
  40963. }
  40964. /**
  40965. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40967. */
  40968. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40969. /**
  40970. * Defines the camera the input is attached to.
  40971. */
  40972. camera: FreeCamera;
  40973. private _leftjoystick;
  40974. private _rightjoystick;
  40975. /**
  40976. * Gets the left stick of the virtual joystick.
  40977. * @returns The virtual Joystick
  40978. */
  40979. getLeftJoystick(): VirtualJoystick;
  40980. /**
  40981. * Gets the right stick of the virtual joystick.
  40982. * @returns The virtual Joystick
  40983. */
  40984. getRightJoystick(): VirtualJoystick;
  40985. /**
  40986. * Update the current camera state depending on the inputs that have been used this frame.
  40987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40988. */
  40989. checkInputs(): void;
  40990. /**
  40991. * Attach the input controls to a specific dom element to get the input from.
  40992. * @param element Defines the element the controls should be listened from
  40993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40994. */
  40995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40996. /**
  40997. * Detach the current controls from the specified dom element.
  40998. * @param element Defines the element to stop listening the inputs from
  40999. */
  41000. detachControl(element: Nullable<HTMLElement>): void;
  41001. /**
  41002. * Gets the class name of the current intput.
  41003. * @returns the class name
  41004. */
  41005. getClassName(): string;
  41006. /**
  41007. * Get the friendly name associated with the input class.
  41008. * @returns the input friendly name
  41009. */
  41010. getSimpleName(): string;
  41011. }
  41012. }
  41013. declare module BABYLON {
  41014. /**
  41015. * This represents a FPS type of camera controlled by touch.
  41016. * This is like a universal camera minus the Gamepad controls.
  41017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41018. */
  41019. export class TouchCamera extends FreeCamera {
  41020. /**
  41021. * Defines the touch sensibility for rotation.
  41022. * The higher the faster.
  41023. */
  41024. get touchAngularSensibility(): number;
  41025. set touchAngularSensibility(value: number);
  41026. /**
  41027. * Defines the touch sensibility for move.
  41028. * The higher the faster.
  41029. */
  41030. get touchMoveSensibility(): number;
  41031. set touchMoveSensibility(value: number);
  41032. /**
  41033. * Instantiates a new touch camera.
  41034. * This represents a FPS type of camera controlled by touch.
  41035. * This is like a universal camera minus the Gamepad controls.
  41036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41037. * @param name Define the name of the camera in the scene
  41038. * @param position Define the start position of the camera in the scene
  41039. * @param scene Define the scene the camera belongs to
  41040. */
  41041. constructor(name: string, position: Vector3, scene: Scene);
  41042. /**
  41043. * Gets the current object class name.
  41044. * @return the class name
  41045. */
  41046. getClassName(): string;
  41047. /** @hidden */
  41048. _setupInputs(): void;
  41049. }
  41050. }
  41051. declare module BABYLON {
  41052. /**
  41053. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41054. * being tilted forward or back and left or right.
  41055. */
  41056. export class DeviceOrientationCamera extends FreeCamera {
  41057. private _initialQuaternion;
  41058. private _quaternionCache;
  41059. private _tmpDragQuaternion;
  41060. private _disablePointerInputWhenUsingDeviceOrientation;
  41061. /**
  41062. * Creates a new device orientation camera
  41063. * @param name The name of the camera
  41064. * @param position The start position camera
  41065. * @param scene The scene the camera belongs to
  41066. */
  41067. constructor(name: string, position: Vector3, scene: Scene);
  41068. /**
  41069. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41070. */
  41071. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41072. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41073. private _dragFactor;
  41074. /**
  41075. * Enabled turning on the y axis when the orientation sensor is active
  41076. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41077. */
  41078. enableHorizontalDragging(dragFactor?: number): void;
  41079. /**
  41080. * Gets the current instance class name ("DeviceOrientationCamera").
  41081. * This helps avoiding instanceof at run time.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * @hidden
  41087. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41088. */
  41089. _checkInputs(): void;
  41090. /**
  41091. * Reset the camera to its default orientation on the specified axis only.
  41092. * @param axis The axis to reset
  41093. */
  41094. resetToCurrentRotation(axis?: Axis): void;
  41095. }
  41096. }
  41097. declare module BABYLON {
  41098. /**
  41099. * Defines supported buttons for XBox360 compatible gamepads
  41100. */
  41101. export enum Xbox360Button {
  41102. /** A */
  41103. A = 0,
  41104. /** B */
  41105. B = 1,
  41106. /** X */
  41107. X = 2,
  41108. /** Y */
  41109. Y = 3,
  41110. /** Left button */
  41111. LB = 4,
  41112. /** Right button */
  41113. RB = 5,
  41114. /** Back */
  41115. Back = 8,
  41116. /** Start */
  41117. Start = 9,
  41118. /** Left stick */
  41119. LeftStick = 10,
  41120. /** Right stick */
  41121. RightStick = 11
  41122. }
  41123. /** Defines values for XBox360 DPad */
  41124. export enum Xbox360Dpad {
  41125. /** Up */
  41126. Up = 12,
  41127. /** Down */
  41128. Down = 13,
  41129. /** Left */
  41130. Left = 14,
  41131. /** Right */
  41132. Right = 15
  41133. }
  41134. /**
  41135. * Defines a XBox360 gamepad
  41136. */
  41137. export class Xbox360Pad extends Gamepad {
  41138. private _leftTrigger;
  41139. private _rightTrigger;
  41140. private _onlefttriggerchanged;
  41141. private _onrighttriggerchanged;
  41142. private _onbuttondown;
  41143. private _onbuttonup;
  41144. private _ondpaddown;
  41145. private _ondpadup;
  41146. /** Observable raised when a button is pressed */
  41147. onButtonDownObservable: Observable<Xbox360Button>;
  41148. /** Observable raised when a button is released */
  41149. onButtonUpObservable: Observable<Xbox360Button>;
  41150. /** Observable raised when a pad is pressed */
  41151. onPadDownObservable: Observable<Xbox360Dpad>;
  41152. /** Observable raised when a pad is released */
  41153. onPadUpObservable: Observable<Xbox360Dpad>;
  41154. private _buttonA;
  41155. private _buttonB;
  41156. private _buttonX;
  41157. private _buttonY;
  41158. private _buttonBack;
  41159. private _buttonStart;
  41160. private _buttonLB;
  41161. private _buttonRB;
  41162. private _buttonLeftStick;
  41163. private _buttonRightStick;
  41164. private _dPadUp;
  41165. private _dPadDown;
  41166. private _dPadLeft;
  41167. private _dPadRight;
  41168. private _isXboxOnePad;
  41169. /**
  41170. * Creates a new XBox360 gamepad object
  41171. * @param id defines the id of this gamepad
  41172. * @param index defines its index
  41173. * @param gamepad defines the internal HTML gamepad object
  41174. * @param xboxOne defines if it is a XBox One gamepad
  41175. */
  41176. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41177. /**
  41178. * Defines the callback to call when left trigger is pressed
  41179. * @param callback defines the callback to use
  41180. */
  41181. onlefttriggerchanged(callback: (value: number) => void): void;
  41182. /**
  41183. * Defines the callback to call when right trigger is pressed
  41184. * @param callback defines the callback to use
  41185. */
  41186. onrighttriggerchanged(callback: (value: number) => void): void;
  41187. /**
  41188. * Gets the left trigger value
  41189. */
  41190. get leftTrigger(): number;
  41191. /**
  41192. * Sets the left trigger value
  41193. */
  41194. set leftTrigger(newValue: number);
  41195. /**
  41196. * Gets the right trigger value
  41197. */
  41198. get rightTrigger(): number;
  41199. /**
  41200. * Sets the right trigger value
  41201. */
  41202. set rightTrigger(newValue: number);
  41203. /**
  41204. * Defines the callback to call when a button is pressed
  41205. * @param callback defines the callback to use
  41206. */
  41207. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41208. /**
  41209. * Defines the callback to call when a button is released
  41210. * @param callback defines the callback to use
  41211. */
  41212. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41213. /**
  41214. * Defines the callback to call when a pad is pressed
  41215. * @param callback defines the callback to use
  41216. */
  41217. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41218. /**
  41219. * Defines the callback to call when a pad is released
  41220. * @param callback defines the callback to use
  41221. */
  41222. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41223. private _setButtonValue;
  41224. private _setDPadValue;
  41225. /**
  41226. * Gets the value of the `A` button
  41227. */
  41228. get buttonA(): number;
  41229. /**
  41230. * Sets the value of the `A` button
  41231. */
  41232. set buttonA(value: number);
  41233. /**
  41234. * Gets the value of the `B` button
  41235. */
  41236. get buttonB(): number;
  41237. /**
  41238. * Sets the value of the `B` button
  41239. */
  41240. set buttonB(value: number);
  41241. /**
  41242. * Gets the value of the `X` button
  41243. */
  41244. get buttonX(): number;
  41245. /**
  41246. * Sets the value of the `X` button
  41247. */
  41248. set buttonX(value: number);
  41249. /**
  41250. * Gets the value of the `Y` button
  41251. */
  41252. get buttonY(): number;
  41253. /**
  41254. * Sets the value of the `Y` button
  41255. */
  41256. set buttonY(value: number);
  41257. /**
  41258. * Gets the value of the `Start` button
  41259. */
  41260. get buttonStart(): number;
  41261. /**
  41262. * Sets the value of the `Start` button
  41263. */
  41264. set buttonStart(value: number);
  41265. /**
  41266. * Gets the value of the `Back` button
  41267. */
  41268. get buttonBack(): number;
  41269. /**
  41270. * Sets the value of the `Back` button
  41271. */
  41272. set buttonBack(value: number);
  41273. /**
  41274. * Gets the value of the `Left` button
  41275. */
  41276. get buttonLB(): number;
  41277. /**
  41278. * Sets the value of the `Left` button
  41279. */
  41280. set buttonLB(value: number);
  41281. /**
  41282. * Gets the value of the `Right` button
  41283. */
  41284. get buttonRB(): number;
  41285. /**
  41286. * Sets the value of the `Right` button
  41287. */
  41288. set buttonRB(value: number);
  41289. /**
  41290. * Gets the value of the Left joystick
  41291. */
  41292. get buttonLeftStick(): number;
  41293. /**
  41294. * Sets the value of the Left joystick
  41295. */
  41296. set buttonLeftStick(value: number);
  41297. /**
  41298. * Gets the value of the Right joystick
  41299. */
  41300. get buttonRightStick(): number;
  41301. /**
  41302. * Sets the value of the Right joystick
  41303. */
  41304. set buttonRightStick(value: number);
  41305. /**
  41306. * Gets the value of D-pad up
  41307. */
  41308. get dPadUp(): number;
  41309. /**
  41310. * Sets the value of D-pad up
  41311. */
  41312. set dPadUp(value: number);
  41313. /**
  41314. * Gets the value of D-pad down
  41315. */
  41316. get dPadDown(): number;
  41317. /**
  41318. * Sets the value of D-pad down
  41319. */
  41320. set dPadDown(value: number);
  41321. /**
  41322. * Gets the value of D-pad left
  41323. */
  41324. get dPadLeft(): number;
  41325. /**
  41326. * Sets the value of D-pad left
  41327. */
  41328. set dPadLeft(value: number);
  41329. /**
  41330. * Gets the value of D-pad right
  41331. */
  41332. get dPadRight(): number;
  41333. /**
  41334. * Sets the value of D-pad right
  41335. */
  41336. set dPadRight(value: number);
  41337. /**
  41338. * Force the gamepad to synchronize with device values
  41339. */
  41340. update(): void;
  41341. /**
  41342. * Disposes the gamepad
  41343. */
  41344. dispose(): void;
  41345. }
  41346. }
  41347. declare module BABYLON {
  41348. /**
  41349. * Defines supported buttons for DualShock compatible gamepads
  41350. */
  41351. export enum DualShockButton {
  41352. /** Cross */
  41353. Cross = 0,
  41354. /** Circle */
  41355. Circle = 1,
  41356. /** Square */
  41357. Square = 2,
  41358. /** Triangle */
  41359. Triangle = 3,
  41360. /** L1 */
  41361. L1 = 4,
  41362. /** R1 */
  41363. R1 = 5,
  41364. /** Share */
  41365. Share = 8,
  41366. /** Options */
  41367. Options = 9,
  41368. /** Left stick */
  41369. LeftStick = 10,
  41370. /** Right stick */
  41371. RightStick = 11
  41372. }
  41373. /** Defines values for DualShock DPad */
  41374. export enum DualShockDpad {
  41375. /** Up */
  41376. Up = 12,
  41377. /** Down */
  41378. Down = 13,
  41379. /** Left */
  41380. Left = 14,
  41381. /** Right */
  41382. Right = 15
  41383. }
  41384. /**
  41385. * Defines a DualShock gamepad
  41386. */
  41387. export class DualShockPad extends Gamepad {
  41388. private _leftTrigger;
  41389. private _rightTrigger;
  41390. private _onlefttriggerchanged;
  41391. private _onrighttriggerchanged;
  41392. private _onbuttondown;
  41393. private _onbuttonup;
  41394. private _ondpaddown;
  41395. private _ondpadup;
  41396. /** Observable raised when a button is pressed */
  41397. onButtonDownObservable: Observable<DualShockButton>;
  41398. /** Observable raised when a button is released */
  41399. onButtonUpObservable: Observable<DualShockButton>;
  41400. /** Observable raised when a pad is pressed */
  41401. onPadDownObservable: Observable<DualShockDpad>;
  41402. /** Observable raised when a pad is released */
  41403. onPadUpObservable: Observable<DualShockDpad>;
  41404. private _buttonCross;
  41405. private _buttonCircle;
  41406. private _buttonSquare;
  41407. private _buttonTriangle;
  41408. private _buttonShare;
  41409. private _buttonOptions;
  41410. private _buttonL1;
  41411. private _buttonR1;
  41412. private _buttonLeftStick;
  41413. private _buttonRightStick;
  41414. private _dPadUp;
  41415. private _dPadDown;
  41416. private _dPadLeft;
  41417. private _dPadRight;
  41418. /**
  41419. * Creates a new DualShock gamepad object
  41420. * @param id defines the id of this gamepad
  41421. * @param index defines its index
  41422. * @param gamepad defines the internal HTML gamepad object
  41423. */
  41424. constructor(id: string, index: number, gamepad: any);
  41425. /**
  41426. * Defines the callback to call when left trigger is pressed
  41427. * @param callback defines the callback to use
  41428. */
  41429. onlefttriggerchanged(callback: (value: number) => void): void;
  41430. /**
  41431. * Defines the callback to call when right trigger is pressed
  41432. * @param callback defines the callback to use
  41433. */
  41434. onrighttriggerchanged(callback: (value: number) => void): void;
  41435. /**
  41436. * Gets the left trigger value
  41437. */
  41438. get leftTrigger(): number;
  41439. /**
  41440. * Sets the left trigger value
  41441. */
  41442. set leftTrigger(newValue: number);
  41443. /**
  41444. * Gets the right trigger value
  41445. */
  41446. get rightTrigger(): number;
  41447. /**
  41448. * Sets the right trigger value
  41449. */
  41450. set rightTrigger(newValue: number);
  41451. /**
  41452. * Defines the callback to call when a button is pressed
  41453. * @param callback defines the callback to use
  41454. */
  41455. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41456. /**
  41457. * Defines the callback to call when a button is released
  41458. * @param callback defines the callback to use
  41459. */
  41460. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41461. /**
  41462. * Defines the callback to call when a pad is pressed
  41463. * @param callback defines the callback to use
  41464. */
  41465. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41466. /**
  41467. * Defines the callback to call when a pad is released
  41468. * @param callback defines the callback to use
  41469. */
  41470. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41471. private _setButtonValue;
  41472. private _setDPadValue;
  41473. /**
  41474. * Gets the value of the `Cross` button
  41475. */
  41476. get buttonCross(): number;
  41477. /**
  41478. * Sets the value of the `Cross` button
  41479. */
  41480. set buttonCross(value: number);
  41481. /**
  41482. * Gets the value of the `Circle` button
  41483. */
  41484. get buttonCircle(): number;
  41485. /**
  41486. * Sets the value of the `Circle` button
  41487. */
  41488. set buttonCircle(value: number);
  41489. /**
  41490. * Gets the value of the `Square` button
  41491. */
  41492. get buttonSquare(): number;
  41493. /**
  41494. * Sets the value of the `Square` button
  41495. */
  41496. set buttonSquare(value: number);
  41497. /**
  41498. * Gets the value of the `Triangle` button
  41499. */
  41500. get buttonTriangle(): number;
  41501. /**
  41502. * Sets the value of the `Triangle` button
  41503. */
  41504. set buttonTriangle(value: number);
  41505. /**
  41506. * Gets the value of the `Options` button
  41507. */
  41508. get buttonOptions(): number;
  41509. /**
  41510. * Sets the value of the `Options` button
  41511. */
  41512. set buttonOptions(value: number);
  41513. /**
  41514. * Gets the value of the `Share` button
  41515. */
  41516. get buttonShare(): number;
  41517. /**
  41518. * Sets the value of the `Share` button
  41519. */
  41520. set buttonShare(value: number);
  41521. /**
  41522. * Gets the value of the `L1` button
  41523. */
  41524. get buttonL1(): number;
  41525. /**
  41526. * Sets the value of the `L1` button
  41527. */
  41528. set buttonL1(value: number);
  41529. /**
  41530. * Gets the value of the `R1` button
  41531. */
  41532. get buttonR1(): number;
  41533. /**
  41534. * Sets the value of the `R1` button
  41535. */
  41536. set buttonR1(value: number);
  41537. /**
  41538. * Gets the value of the Left joystick
  41539. */
  41540. get buttonLeftStick(): number;
  41541. /**
  41542. * Sets the value of the Left joystick
  41543. */
  41544. set buttonLeftStick(value: number);
  41545. /**
  41546. * Gets the value of the Right joystick
  41547. */
  41548. get buttonRightStick(): number;
  41549. /**
  41550. * Sets the value of the Right joystick
  41551. */
  41552. set buttonRightStick(value: number);
  41553. /**
  41554. * Gets the value of D-pad up
  41555. */
  41556. get dPadUp(): number;
  41557. /**
  41558. * Sets the value of D-pad up
  41559. */
  41560. set dPadUp(value: number);
  41561. /**
  41562. * Gets the value of D-pad down
  41563. */
  41564. get dPadDown(): number;
  41565. /**
  41566. * Sets the value of D-pad down
  41567. */
  41568. set dPadDown(value: number);
  41569. /**
  41570. * Gets the value of D-pad left
  41571. */
  41572. get dPadLeft(): number;
  41573. /**
  41574. * Sets the value of D-pad left
  41575. */
  41576. set dPadLeft(value: number);
  41577. /**
  41578. * Gets the value of D-pad right
  41579. */
  41580. get dPadRight(): number;
  41581. /**
  41582. * Sets the value of D-pad right
  41583. */
  41584. set dPadRight(value: number);
  41585. /**
  41586. * Force the gamepad to synchronize with device values
  41587. */
  41588. update(): void;
  41589. /**
  41590. * Disposes the gamepad
  41591. */
  41592. dispose(): void;
  41593. }
  41594. }
  41595. declare module BABYLON {
  41596. /**
  41597. * Manager for handling gamepads
  41598. */
  41599. export class GamepadManager {
  41600. private _scene?;
  41601. private _babylonGamepads;
  41602. private _oneGamepadConnected;
  41603. /** @hidden */
  41604. _isMonitoring: boolean;
  41605. private _gamepadEventSupported;
  41606. private _gamepadSupport?;
  41607. /**
  41608. * observable to be triggered when the gamepad controller has been connected
  41609. */
  41610. onGamepadConnectedObservable: Observable<Gamepad>;
  41611. /**
  41612. * observable to be triggered when the gamepad controller has been disconnected
  41613. */
  41614. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41615. private _onGamepadConnectedEvent;
  41616. private _onGamepadDisconnectedEvent;
  41617. /**
  41618. * Initializes the gamepad manager
  41619. * @param _scene BabylonJS scene
  41620. */
  41621. constructor(_scene?: Scene | undefined);
  41622. /**
  41623. * The gamepads in the game pad manager
  41624. */
  41625. get gamepads(): Gamepad[];
  41626. /**
  41627. * Get the gamepad controllers based on type
  41628. * @param type The type of gamepad controller
  41629. * @returns Nullable gamepad
  41630. */
  41631. getGamepadByType(type?: number): Nullable<Gamepad>;
  41632. /**
  41633. * Disposes the gamepad manager
  41634. */
  41635. dispose(): void;
  41636. private _addNewGamepad;
  41637. private _startMonitoringGamepads;
  41638. private _stopMonitoringGamepads;
  41639. /** @hidden */
  41640. _checkGamepadsStatus(): void;
  41641. private _updateGamepadObjects;
  41642. }
  41643. }
  41644. declare module BABYLON {
  41645. interface Scene {
  41646. /** @hidden */
  41647. _gamepadManager: Nullable<GamepadManager>;
  41648. /**
  41649. * Gets the gamepad manager associated with the scene
  41650. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41651. */
  41652. gamepadManager: GamepadManager;
  41653. }
  41654. /**
  41655. * Interface representing a free camera inputs manager
  41656. */
  41657. interface FreeCameraInputsManager {
  41658. /**
  41659. * Adds gamepad input support to the FreeCameraInputsManager.
  41660. * @returns the FreeCameraInputsManager
  41661. */
  41662. addGamepad(): FreeCameraInputsManager;
  41663. }
  41664. /**
  41665. * Interface representing an arc rotate camera inputs manager
  41666. */
  41667. interface ArcRotateCameraInputsManager {
  41668. /**
  41669. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41670. * @returns the camera inputs manager
  41671. */
  41672. addGamepad(): ArcRotateCameraInputsManager;
  41673. }
  41674. /**
  41675. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41676. */
  41677. export class GamepadSystemSceneComponent implements ISceneComponent {
  41678. /**
  41679. * The component name helpfull to identify the component in the list of scene components.
  41680. */
  41681. readonly name: string;
  41682. /**
  41683. * The scene the component belongs to.
  41684. */
  41685. scene: Scene;
  41686. /**
  41687. * Creates a new instance of the component for the given scene
  41688. * @param scene Defines the scene to register the component in
  41689. */
  41690. constructor(scene: Scene);
  41691. /**
  41692. * Registers the component in a given scene
  41693. */
  41694. register(): void;
  41695. /**
  41696. * Rebuilds the elements related to this component in case of
  41697. * context lost for instance.
  41698. */
  41699. rebuild(): void;
  41700. /**
  41701. * Disposes the component and the associated ressources
  41702. */
  41703. dispose(): void;
  41704. private _beforeCameraUpdate;
  41705. }
  41706. }
  41707. declare module BABYLON {
  41708. /**
  41709. * 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,
  41710. * which still works and will still be found in many Playgrounds.
  41711. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41712. */
  41713. export class UniversalCamera extends TouchCamera {
  41714. /**
  41715. * Defines the gamepad rotation sensiblity.
  41716. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41717. */
  41718. get gamepadAngularSensibility(): number;
  41719. set gamepadAngularSensibility(value: number);
  41720. /**
  41721. * Defines the gamepad move sensiblity.
  41722. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41723. */
  41724. get gamepadMoveSensibility(): number;
  41725. set gamepadMoveSensibility(value: number);
  41726. /**
  41727. * 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,
  41728. * which still works and will still be found in many Playgrounds.
  41729. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41730. * @param name Define the name of the camera in the scene
  41731. * @param position Define the start position of the camera in the scene
  41732. * @param scene Define the scene the camera belongs to
  41733. */
  41734. constructor(name: string, position: Vector3, scene: Scene);
  41735. /**
  41736. * Gets the current object class name.
  41737. * @return the class name
  41738. */
  41739. getClassName(): string;
  41740. }
  41741. }
  41742. declare module BABYLON {
  41743. /**
  41744. * This represents a FPS type of camera. This is only here for back compat purpose.
  41745. * Please use the UniversalCamera instead as both are identical.
  41746. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41747. */
  41748. export class GamepadCamera extends UniversalCamera {
  41749. /**
  41750. * Instantiates a new Gamepad Camera
  41751. * This represents a FPS type of camera. This is only here for back compat purpose.
  41752. * Please use the UniversalCamera instead as both are identical.
  41753. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41754. * @param name Define the name of the camera in the scene
  41755. * @param position Define the start position of the camera in the scene
  41756. * @param scene Define the scene the camera belongs to
  41757. */
  41758. constructor(name: string, position: Vector3, scene: Scene);
  41759. /**
  41760. * Gets the current object class name.
  41761. * @return the class name
  41762. */
  41763. getClassName(): string;
  41764. }
  41765. }
  41766. declare module BABYLON {
  41767. /** @hidden */
  41768. export var passPixelShader: {
  41769. name: string;
  41770. shader: string;
  41771. };
  41772. }
  41773. declare module BABYLON {
  41774. /** @hidden */
  41775. export var passCubePixelShader: {
  41776. name: string;
  41777. shader: string;
  41778. };
  41779. }
  41780. declare module BABYLON {
  41781. /**
  41782. * PassPostProcess which produces an output the same as it's input
  41783. */
  41784. export class PassPostProcess extends PostProcess {
  41785. /**
  41786. * Creates the PassPostProcess
  41787. * @param name The name of the effect.
  41788. * @param options The required width/height ratio to downsize to before computing the render pass.
  41789. * @param camera The camera to apply the render pass to.
  41790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41791. * @param engine The engine which the post process will be applied. (default: current engine)
  41792. * @param reusable If the post process can be reused on the same frame. (default: false)
  41793. * @param textureType The type of texture to be used when performing the post processing.
  41794. * @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)
  41795. */
  41796. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41797. }
  41798. /**
  41799. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41800. */
  41801. export class PassCubePostProcess extends PostProcess {
  41802. private _face;
  41803. /**
  41804. * Gets or sets the cube face to display.
  41805. * * 0 is +X
  41806. * * 1 is -X
  41807. * * 2 is +Y
  41808. * * 3 is -Y
  41809. * * 4 is +Z
  41810. * * 5 is -Z
  41811. */
  41812. get face(): number;
  41813. set face(value: number);
  41814. /**
  41815. * Creates the PassCubePostProcess
  41816. * @param name The name of the effect.
  41817. * @param options The required width/height ratio to downsize to before computing the render pass.
  41818. * @param camera The camera to apply the render pass to.
  41819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41820. * @param engine The engine which the post process will be applied. (default: current engine)
  41821. * @param reusable If the post process can be reused on the same frame. (default: false)
  41822. * @param textureType The type of texture to be used when performing the post processing.
  41823. * @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)
  41824. */
  41825. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41826. }
  41827. }
  41828. declare module BABYLON {
  41829. /** @hidden */
  41830. export var anaglyphPixelShader: {
  41831. name: string;
  41832. shader: string;
  41833. };
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Postprocess used to generate anaglyphic rendering
  41838. */
  41839. export class AnaglyphPostProcess extends PostProcess {
  41840. private _passedProcess;
  41841. /**
  41842. * Creates a new AnaglyphPostProcess
  41843. * @param name defines postprocess name
  41844. * @param options defines creation options or target ratio scale
  41845. * @param rigCameras defines cameras using this postprocess
  41846. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41847. * @param engine defines hosting engine
  41848. * @param reusable defines if the postprocess will be reused multiple times per frame
  41849. */
  41850. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /**
  41855. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41856. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41857. */
  41858. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41859. /**
  41860. * Creates a new AnaglyphArcRotateCamera
  41861. * @param name defines camera name
  41862. * @param alpha defines alpha angle (in radians)
  41863. * @param beta defines beta angle (in radians)
  41864. * @param radius defines radius
  41865. * @param target defines camera target
  41866. * @param interaxialDistance defines distance between each color axis
  41867. * @param scene defines the hosting scene
  41868. */
  41869. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41870. /**
  41871. * Gets camera class name
  41872. * @returns AnaglyphArcRotateCamera
  41873. */
  41874. getClassName(): string;
  41875. }
  41876. }
  41877. declare module BABYLON {
  41878. /**
  41879. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41880. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41881. */
  41882. export class AnaglyphFreeCamera extends FreeCamera {
  41883. /**
  41884. * Creates a new AnaglyphFreeCamera
  41885. * @param name defines camera name
  41886. * @param position defines initial position
  41887. * @param interaxialDistance defines distance between each color axis
  41888. * @param scene defines the hosting scene
  41889. */
  41890. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41891. /**
  41892. * Gets camera class name
  41893. * @returns AnaglyphFreeCamera
  41894. */
  41895. getClassName(): string;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. /**
  41900. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41901. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41902. */
  41903. export class AnaglyphGamepadCamera extends GamepadCamera {
  41904. /**
  41905. * Creates a new AnaglyphGamepadCamera
  41906. * @param name defines camera name
  41907. * @param position defines initial position
  41908. * @param interaxialDistance defines distance between each color axis
  41909. * @param scene defines the hosting scene
  41910. */
  41911. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41912. /**
  41913. * Gets camera class name
  41914. * @returns AnaglyphGamepadCamera
  41915. */
  41916. getClassName(): string;
  41917. }
  41918. }
  41919. declare module BABYLON {
  41920. /**
  41921. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41922. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41923. */
  41924. export class AnaglyphUniversalCamera extends UniversalCamera {
  41925. /**
  41926. * Creates a new AnaglyphUniversalCamera
  41927. * @param name defines camera name
  41928. * @param position defines initial position
  41929. * @param interaxialDistance defines distance between each color axis
  41930. * @param scene defines the hosting scene
  41931. */
  41932. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41933. /**
  41934. * Gets camera class name
  41935. * @returns AnaglyphUniversalCamera
  41936. */
  41937. getClassName(): string;
  41938. }
  41939. }
  41940. declare module BABYLON {
  41941. /** @hidden */
  41942. export var stereoscopicInterlacePixelShader: {
  41943. name: string;
  41944. shader: string;
  41945. };
  41946. }
  41947. declare module BABYLON {
  41948. /**
  41949. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41950. */
  41951. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41952. private _stepSize;
  41953. private _passedProcess;
  41954. /**
  41955. * Initializes a StereoscopicInterlacePostProcessI
  41956. * @param name The name of the effect.
  41957. * @param rigCameras The rig cameras to be appled to the post process
  41958. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41959. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41961. * @param engine The engine which the post process will be applied. (default: current engine)
  41962. * @param reusable If the post process can be reused on the same frame. (default: false)
  41963. */
  41964. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41965. }
  41966. /**
  41967. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41968. */
  41969. export class StereoscopicInterlacePostProcess extends PostProcess {
  41970. private _stepSize;
  41971. private _passedProcess;
  41972. /**
  41973. * Initializes a StereoscopicInterlacePostProcess
  41974. * @param name The name of the effect.
  41975. * @param rigCameras The rig cameras to be appled to the post process
  41976. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41978. * @param engine The engine which the post process will be applied. (default: current engine)
  41979. * @param reusable If the post process can be reused on the same frame. (default: false)
  41980. */
  41981. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41982. }
  41983. }
  41984. declare module BABYLON {
  41985. /**
  41986. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41987. * @see http://doc.babylonjs.com/features/cameras
  41988. */
  41989. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41990. /**
  41991. * Creates a new StereoscopicArcRotateCamera
  41992. * @param name defines camera name
  41993. * @param alpha defines alpha angle (in radians)
  41994. * @param beta defines beta angle (in radians)
  41995. * @param radius defines radius
  41996. * @param target defines camera target
  41997. * @param interaxialDistance defines distance between each color axis
  41998. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41999. * @param scene defines the hosting scene
  42000. */
  42001. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42002. /**
  42003. * Gets camera class name
  42004. * @returns StereoscopicArcRotateCamera
  42005. */
  42006. getClassName(): string;
  42007. }
  42008. }
  42009. declare module BABYLON {
  42010. /**
  42011. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42012. * @see http://doc.babylonjs.com/features/cameras
  42013. */
  42014. export class StereoscopicFreeCamera extends FreeCamera {
  42015. /**
  42016. * Creates a new StereoscopicFreeCamera
  42017. * @param name defines camera name
  42018. * @param position defines initial position
  42019. * @param interaxialDistance defines distance between each color axis
  42020. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42021. * @param scene defines the hosting scene
  42022. */
  42023. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42024. /**
  42025. * Gets camera class name
  42026. * @returns StereoscopicFreeCamera
  42027. */
  42028. getClassName(): string;
  42029. }
  42030. }
  42031. declare module BABYLON {
  42032. /**
  42033. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42034. * @see http://doc.babylonjs.com/features/cameras
  42035. */
  42036. export class StereoscopicGamepadCamera extends GamepadCamera {
  42037. /**
  42038. * Creates a new StereoscopicGamepadCamera
  42039. * @param name defines camera name
  42040. * @param position defines initial position
  42041. * @param interaxialDistance defines distance between each color axis
  42042. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42043. * @param scene defines the hosting scene
  42044. */
  42045. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42046. /**
  42047. * Gets camera class name
  42048. * @returns StereoscopicGamepadCamera
  42049. */
  42050. getClassName(): string;
  42051. }
  42052. }
  42053. declare module BABYLON {
  42054. /**
  42055. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42056. * @see http://doc.babylonjs.com/features/cameras
  42057. */
  42058. export class StereoscopicUniversalCamera extends UniversalCamera {
  42059. /**
  42060. * Creates a new StereoscopicUniversalCamera
  42061. * @param name defines camera name
  42062. * @param position defines initial position
  42063. * @param interaxialDistance defines distance between each color axis
  42064. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42065. * @param scene defines the hosting scene
  42066. */
  42067. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42068. /**
  42069. * Gets camera class name
  42070. * @returns StereoscopicUniversalCamera
  42071. */
  42072. getClassName(): string;
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42078. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42079. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42080. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42081. */
  42082. export class VirtualJoysticksCamera extends FreeCamera {
  42083. /**
  42084. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42085. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42086. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42087. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42088. * @param name Define the name of the camera in the scene
  42089. * @param position Define the start position of the camera in the scene
  42090. * @param scene Define the scene the camera belongs to
  42091. */
  42092. constructor(name: string, position: Vector3, scene: Scene);
  42093. /**
  42094. * Gets the current object class name.
  42095. * @return the class name
  42096. */
  42097. getClassName(): string;
  42098. }
  42099. }
  42100. declare module BABYLON {
  42101. /**
  42102. * This represents all the required metrics to create a VR camera.
  42103. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42104. */
  42105. export class VRCameraMetrics {
  42106. /**
  42107. * Define the horizontal resolution off the screen.
  42108. */
  42109. hResolution: number;
  42110. /**
  42111. * Define the vertical resolution off the screen.
  42112. */
  42113. vResolution: number;
  42114. /**
  42115. * Define the horizontal screen size.
  42116. */
  42117. hScreenSize: number;
  42118. /**
  42119. * Define the vertical screen size.
  42120. */
  42121. vScreenSize: number;
  42122. /**
  42123. * Define the vertical screen center position.
  42124. */
  42125. vScreenCenter: number;
  42126. /**
  42127. * Define the distance of the eyes to the screen.
  42128. */
  42129. eyeToScreenDistance: number;
  42130. /**
  42131. * Define the distance between both lenses
  42132. */
  42133. lensSeparationDistance: number;
  42134. /**
  42135. * Define the distance between both viewer's eyes.
  42136. */
  42137. interpupillaryDistance: number;
  42138. /**
  42139. * Define the distortion factor of the VR postprocess.
  42140. * Please, touch with care.
  42141. */
  42142. distortionK: number[];
  42143. /**
  42144. * Define the chromatic aberration correction factors for the VR post process.
  42145. */
  42146. chromaAbCorrection: number[];
  42147. /**
  42148. * Define the scale factor of the post process.
  42149. * The smaller the better but the slower.
  42150. */
  42151. postProcessScaleFactor: number;
  42152. /**
  42153. * Define an offset for the lens center.
  42154. */
  42155. lensCenterOffset: number;
  42156. /**
  42157. * Define if the current vr camera should compensate the distortion of the lense or not.
  42158. */
  42159. compensateDistortion: boolean;
  42160. /**
  42161. * Defines if multiview should be enabled when rendering (Default: false)
  42162. */
  42163. multiviewEnabled: boolean;
  42164. /**
  42165. * Gets the rendering aspect ratio based on the provided resolutions.
  42166. */
  42167. get aspectRatio(): number;
  42168. /**
  42169. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42170. */
  42171. get aspectRatioFov(): number;
  42172. /**
  42173. * @hidden
  42174. */
  42175. get leftHMatrix(): Matrix;
  42176. /**
  42177. * @hidden
  42178. */
  42179. get rightHMatrix(): Matrix;
  42180. /**
  42181. * @hidden
  42182. */
  42183. get leftPreViewMatrix(): Matrix;
  42184. /**
  42185. * @hidden
  42186. */
  42187. get rightPreViewMatrix(): Matrix;
  42188. /**
  42189. * Get the default VRMetrics based on the most generic setup.
  42190. * @returns the default vr metrics
  42191. */
  42192. static GetDefault(): VRCameraMetrics;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /** @hidden */
  42197. export var vrDistortionCorrectionPixelShader: {
  42198. name: string;
  42199. shader: string;
  42200. };
  42201. }
  42202. declare module BABYLON {
  42203. /**
  42204. * VRDistortionCorrectionPostProcess used for mobile VR
  42205. */
  42206. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42207. private _isRightEye;
  42208. private _distortionFactors;
  42209. private _postProcessScaleFactor;
  42210. private _lensCenterOffset;
  42211. private _scaleIn;
  42212. private _scaleFactor;
  42213. private _lensCenter;
  42214. /**
  42215. * Initializes the VRDistortionCorrectionPostProcess
  42216. * @param name The name of the effect.
  42217. * @param camera The camera to apply the render pass to.
  42218. * @param isRightEye If this is for the right eye distortion
  42219. * @param vrMetrics All the required metrics for the VR camera
  42220. */
  42221. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42222. }
  42223. }
  42224. declare module BABYLON {
  42225. /**
  42226. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42227. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42228. */
  42229. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42230. /**
  42231. * Creates a new VRDeviceOrientationArcRotateCamera
  42232. * @param name defines camera name
  42233. * @param alpha defines the camera rotation along the logitudinal axis
  42234. * @param beta defines the camera rotation along the latitudinal axis
  42235. * @param radius defines the camera distance from its target
  42236. * @param target defines the camera target
  42237. * @param scene defines the scene the camera belongs to
  42238. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42239. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42240. */
  42241. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42242. /**
  42243. * Gets camera class name
  42244. * @returns VRDeviceOrientationArcRotateCamera
  42245. */
  42246. getClassName(): string;
  42247. }
  42248. }
  42249. declare module BABYLON {
  42250. /**
  42251. * Camera used to simulate VR rendering (based on FreeCamera)
  42252. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42253. */
  42254. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42255. /**
  42256. * Creates a new VRDeviceOrientationFreeCamera
  42257. * @param name defines camera name
  42258. * @param position defines the start position of the camera
  42259. * @param scene defines the scene the camera belongs to
  42260. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42261. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42262. */
  42263. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42264. /**
  42265. * Gets camera class name
  42266. * @returns VRDeviceOrientationFreeCamera
  42267. */
  42268. getClassName(): string;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42274. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42275. */
  42276. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42277. /**
  42278. * Creates a new VRDeviceOrientationGamepadCamera
  42279. * @param name defines camera name
  42280. * @param position defines the start position of the camera
  42281. * @param scene defines the scene the camera belongs to
  42282. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42283. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42284. */
  42285. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42286. /**
  42287. * Gets camera class name
  42288. * @returns VRDeviceOrientationGamepadCamera
  42289. */
  42290. getClassName(): string;
  42291. }
  42292. }
  42293. declare module BABYLON {
  42294. /** @hidden */
  42295. export var imageProcessingPixelShader: {
  42296. name: string;
  42297. shader: string;
  42298. };
  42299. }
  42300. declare module BABYLON {
  42301. /**
  42302. * ImageProcessingPostProcess
  42303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42304. */
  42305. export class ImageProcessingPostProcess extends PostProcess {
  42306. /**
  42307. * Default configuration related to image processing available in the PBR Material.
  42308. */
  42309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42310. /**
  42311. * Gets the image processing configuration used either in this material.
  42312. */
  42313. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42314. /**
  42315. * Sets the Default image processing configuration used either in the this material.
  42316. *
  42317. * If sets to null, the scene one is in use.
  42318. */
  42319. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42320. /**
  42321. * Keep track of the image processing observer to allow dispose and replace.
  42322. */
  42323. private _imageProcessingObserver;
  42324. /**
  42325. * Attaches a new image processing configuration to the PBR Material.
  42326. * @param configuration
  42327. */
  42328. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42329. /**
  42330. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42331. */
  42332. get colorCurves(): Nullable<ColorCurves>;
  42333. /**
  42334. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42335. */
  42336. set colorCurves(value: Nullable<ColorCurves>);
  42337. /**
  42338. * Gets wether the color curves effect is enabled.
  42339. */
  42340. get colorCurvesEnabled(): boolean;
  42341. /**
  42342. * Sets wether the color curves effect is enabled.
  42343. */
  42344. set colorCurvesEnabled(value: boolean);
  42345. /**
  42346. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42347. */
  42348. get colorGradingTexture(): Nullable<BaseTexture>;
  42349. /**
  42350. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42351. */
  42352. set colorGradingTexture(value: Nullable<BaseTexture>);
  42353. /**
  42354. * Gets wether the color grading effect is enabled.
  42355. */
  42356. get colorGradingEnabled(): boolean;
  42357. /**
  42358. * Gets wether the color grading effect is enabled.
  42359. */
  42360. set colorGradingEnabled(value: boolean);
  42361. /**
  42362. * Gets exposure used in the effect.
  42363. */
  42364. get exposure(): number;
  42365. /**
  42366. * Sets exposure used in the effect.
  42367. */
  42368. set exposure(value: number);
  42369. /**
  42370. * Gets wether tonemapping is enabled or not.
  42371. */
  42372. get toneMappingEnabled(): boolean;
  42373. /**
  42374. * Sets wether tonemapping is enabled or not
  42375. */
  42376. set toneMappingEnabled(value: boolean);
  42377. /**
  42378. * Gets the type of tone mapping effect.
  42379. */
  42380. get toneMappingType(): number;
  42381. /**
  42382. * Sets the type of tone mapping effect.
  42383. */
  42384. set toneMappingType(value: number);
  42385. /**
  42386. * Gets contrast used in the effect.
  42387. */
  42388. get contrast(): number;
  42389. /**
  42390. * Sets contrast used in the effect.
  42391. */
  42392. set contrast(value: number);
  42393. /**
  42394. * Gets Vignette stretch size.
  42395. */
  42396. get vignetteStretch(): number;
  42397. /**
  42398. * Sets Vignette stretch size.
  42399. */
  42400. set vignetteStretch(value: number);
  42401. /**
  42402. * Gets Vignette centre X Offset.
  42403. */
  42404. get vignetteCentreX(): number;
  42405. /**
  42406. * Sets Vignette centre X Offset.
  42407. */
  42408. set vignetteCentreX(value: number);
  42409. /**
  42410. * Gets Vignette centre Y Offset.
  42411. */
  42412. get vignetteCentreY(): number;
  42413. /**
  42414. * Sets Vignette centre Y Offset.
  42415. */
  42416. set vignetteCentreY(value: number);
  42417. /**
  42418. * Gets Vignette weight or intensity of the vignette effect.
  42419. */
  42420. get vignetteWeight(): number;
  42421. /**
  42422. * Sets Vignette weight or intensity of the vignette effect.
  42423. */
  42424. set vignetteWeight(value: number);
  42425. /**
  42426. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42427. * if vignetteEnabled is set to true.
  42428. */
  42429. get vignetteColor(): Color4;
  42430. /**
  42431. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42432. * if vignetteEnabled is set to true.
  42433. */
  42434. set vignetteColor(value: Color4);
  42435. /**
  42436. * Gets Camera field of view used by the Vignette effect.
  42437. */
  42438. get vignetteCameraFov(): number;
  42439. /**
  42440. * Sets Camera field of view used by the Vignette effect.
  42441. */
  42442. set vignetteCameraFov(value: number);
  42443. /**
  42444. * Gets the vignette blend mode allowing different kind of effect.
  42445. */
  42446. get vignetteBlendMode(): number;
  42447. /**
  42448. * Sets the vignette blend mode allowing different kind of effect.
  42449. */
  42450. set vignetteBlendMode(value: number);
  42451. /**
  42452. * Gets wether the vignette effect is enabled.
  42453. */
  42454. get vignetteEnabled(): boolean;
  42455. /**
  42456. * Sets wether the vignette effect is enabled.
  42457. */
  42458. set vignetteEnabled(value: boolean);
  42459. private _fromLinearSpace;
  42460. /**
  42461. * Gets wether the input of the processing is in Gamma or Linear Space.
  42462. */
  42463. get fromLinearSpace(): boolean;
  42464. /**
  42465. * Sets wether the input of the processing is in Gamma or Linear Space.
  42466. */
  42467. set fromLinearSpace(value: boolean);
  42468. /**
  42469. * Defines cache preventing GC.
  42470. */
  42471. private _defines;
  42472. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42473. /**
  42474. * "ImageProcessingPostProcess"
  42475. * @returns "ImageProcessingPostProcess"
  42476. */
  42477. getClassName(): string;
  42478. protected _updateParameters(): void;
  42479. dispose(camera?: Camera): void;
  42480. }
  42481. }
  42482. declare module BABYLON {
  42483. /**
  42484. * Class containing static functions to help procedurally build meshes
  42485. */
  42486. export class GroundBuilder {
  42487. /**
  42488. * Creates a ground mesh
  42489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42492. * @param name defines the name of the mesh
  42493. * @param options defines the options used to create the mesh
  42494. * @param scene defines the hosting scene
  42495. * @returns the ground mesh
  42496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42497. */
  42498. static CreateGround(name: string, options: {
  42499. width?: number;
  42500. height?: number;
  42501. subdivisions?: number;
  42502. subdivisionsX?: number;
  42503. subdivisionsY?: number;
  42504. updatable?: boolean;
  42505. }, scene: any): Mesh;
  42506. /**
  42507. * Creates a tiled ground mesh
  42508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42510. * * 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
  42511. * * 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
  42512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42513. * @param name defines the name of the mesh
  42514. * @param options defines the options used to create the mesh
  42515. * @param scene defines the hosting scene
  42516. * @returns the tiled ground mesh
  42517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42518. */
  42519. static CreateTiledGround(name: string, options: {
  42520. xmin: number;
  42521. zmin: number;
  42522. xmax: number;
  42523. zmax: number;
  42524. subdivisions?: {
  42525. w: number;
  42526. h: number;
  42527. };
  42528. precision?: {
  42529. w: number;
  42530. h: number;
  42531. };
  42532. updatable?: boolean;
  42533. }, scene?: Nullable<Scene>): Mesh;
  42534. /**
  42535. * Creates a ground mesh from a height map
  42536. * * The parameter `url` sets the URL of the height map image resource.
  42537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42541. * * 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.
  42542. * * 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).
  42543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42545. * @param name defines the name of the mesh
  42546. * @param url defines the url to the height map
  42547. * @param options defines the options used to create the mesh
  42548. * @param scene defines the hosting scene
  42549. * @returns the ground mesh
  42550. * @see https://doc.babylonjs.com/babylon101/height_map
  42551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42552. */
  42553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42554. width?: number;
  42555. height?: number;
  42556. subdivisions?: number;
  42557. minHeight?: number;
  42558. maxHeight?: number;
  42559. colorFilter?: Color3;
  42560. alphaFilter?: number;
  42561. updatable?: boolean;
  42562. onReady?: (mesh: GroundMesh) => void;
  42563. }, scene?: Nullable<Scene>): GroundMesh;
  42564. }
  42565. }
  42566. declare module BABYLON {
  42567. /**
  42568. * Class containing static functions to help procedurally build meshes
  42569. */
  42570. export class TorusBuilder {
  42571. /**
  42572. * Creates a torus mesh
  42573. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42574. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42575. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42577. * * 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
  42578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42579. * @param name defines the name of the mesh
  42580. * @param options defines the options used to create the mesh
  42581. * @param scene defines the hosting scene
  42582. * @returns the torus mesh
  42583. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42584. */
  42585. static CreateTorus(name: string, options: {
  42586. diameter?: number;
  42587. thickness?: number;
  42588. tessellation?: number;
  42589. updatable?: boolean;
  42590. sideOrientation?: number;
  42591. frontUVs?: Vector4;
  42592. backUVs?: Vector4;
  42593. }, scene: any): Mesh;
  42594. }
  42595. }
  42596. declare module BABYLON {
  42597. /**
  42598. * Class containing static functions to help procedurally build meshes
  42599. */
  42600. export class CylinderBuilder {
  42601. /**
  42602. * Creates a cylinder or a cone mesh
  42603. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42604. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42605. * * 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.
  42606. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42607. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42608. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42609. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42610. * * 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).
  42611. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42612. * * 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).
  42613. * * 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
  42614. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42615. * * 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
  42616. * * 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.
  42617. * * If `enclose` is false, a ring surface is one element.
  42618. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42619. * * 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
  42620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42621. * * 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
  42622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42623. * @param name defines the name of the mesh
  42624. * @param options defines the options used to create the mesh
  42625. * @param scene defines the hosting scene
  42626. * @returns the cylinder mesh
  42627. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42628. */
  42629. static CreateCylinder(name: string, options: {
  42630. height?: number;
  42631. diameterTop?: number;
  42632. diameterBottom?: number;
  42633. diameter?: number;
  42634. tessellation?: number;
  42635. subdivisions?: number;
  42636. arc?: number;
  42637. faceColors?: Color4[];
  42638. faceUV?: Vector4[];
  42639. updatable?: boolean;
  42640. hasRings?: boolean;
  42641. enclose?: boolean;
  42642. cap?: number;
  42643. sideOrientation?: number;
  42644. frontUVs?: Vector4;
  42645. backUVs?: Vector4;
  42646. }, scene: any): Mesh;
  42647. }
  42648. }
  42649. declare module BABYLON {
  42650. /**
  42651. * States of the webXR experience
  42652. */
  42653. export enum WebXRState {
  42654. /**
  42655. * Transitioning to being in XR mode
  42656. */
  42657. ENTERING_XR = 0,
  42658. /**
  42659. * Transitioning to non XR mode
  42660. */
  42661. EXITING_XR = 1,
  42662. /**
  42663. * In XR mode and presenting
  42664. */
  42665. IN_XR = 2,
  42666. /**
  42667. * Not entered XR mode
  42668. */
  42669. NOT_IN_XR = 3
  42670. }
  42671. /**
  42672. * Abstraction of the XR render target
  42673. */
  42674. export interface WebXRRenderTarget extends IDisposable {
  42675. /**
  42676. * xrpresent context of the canvas which can be used to display/mirror xr content
  42677. */
  42678. canvasContext: WebGLRenderingContext;
  42679. /**
  42680. * xr layer for the canvas
  42681. */
  42682. xrLayer: Nullable<XRWebGLLayer>;
  42683. /**
  42684. * Initializes the xr layer for the session
  42685. * @param xrSession xr session
  42686. * @returns a promise that will resolve once the XR Layer has been created
  42687. */
  42688. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42689. }
  42690. }
  42691. declare module BABYLON {
  42692. /**
  42693. * COnfiguration object for WebXR output canvas
  42694. */
  42695. export class WebXRManagedOutputCanvasOptions {
  42696. /**
  42697. * An optional canvas in case you wish to create it yourself and provide it here.
  42698. * If not provided, a new canvas will be created
  42699. */
  42700. canvasElement?: HTMLCanvasElement;
  42701. /**
  42702. * Options for this XR Layer output
  42703. */
  42704. canvasOptions?: XRWebGLLayerOptions;
  42705. /**
  42706. * CSS styling for a newly created canvas (if not provided)
  42707. */
  42708. newCanvasCssStyle?: string;
  42709. /**
  42710. * Get the default values of the configuration object
  42711. * @returns default values of this configuration object
  42712. */
  42713. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42714. }
  42715. /**
  42716. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42717. */
  42718. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42719. private _options;
  42720. private _canvas;
  42721. private _engine;
  42722. /**
  42723. * Rendering context of the canvas which can be used to display/mirror xr content
  42724. */
  42725. canvasContext: WebGLRenderingContext;
  42726. /**
  42727. * xr layer for the canvas
  42728. */
  42729. xrLayer: Nullable<XRWebGLLayer>;
  42730. /**
  42731. * Initializes the canvas to be added/removed upon entering/exiting xr
  42732. * @param _xrSessionManager The XR Session manager
  42733. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42734. */
  42735. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42736. /**
  42737. * Disposes of the object
  42738. */
  42739. dispose(): void;
  42740. /**
  42741. * Initializes the xr layer for the session
  42742. * @param xrSession xr session
  42743. * @returns a promise that will resolve once the XR Layer has been created
  42744. */
  42745. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42746. private _addCanvas;
  42747. private _removeCanvas;
  42748. private _setManagedOutputCanvas;
  42749. }
  42750. }
  42751. declare module BABYLON {
  42752. /**
  42753. * Manages an XRSession to work with Babylon's engine
  42754. * @see https://doc.babylonjs.com/how_to/webxr
  42755. */
  42756. export class WebXRSessionManager implements IDisposable {
  42757. /** The scene which the session should be created for */
  42758. scene: Scene;
  42759. private _referenceSpace;
  42760. private _rttProvider;
  42761. private _sessionEnded;
  42762. private _xrNavigator;
  42763. private baseLayer;
  42764. /**
  42765. * The base reference space from which the session started. good if you want to reset your
  42766. * reference space
  42767. */
  42768. baseReferenceSpace: XRReferenceSpace;
  42769. /**
  42770. * Current XR frame
  42771. */
  42772. currentFrame: Nullable<XRFrame>;
  42773. /** WebXR timestamp updated every frame */
  42774. currentTimestamp: number;
  42775. /**
  42776. * Used just in case of a failure to initialize an immersive session.
  42777. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42778. */
  42779. defaultHeightCompensation: number;
  42780. /**
  42781. * Fires every time a new xrFrame arrives which can be used to update the camera
  42782. */
  42783. onXRFrameObservable: Observable<XRFrame>;
  42784. /**
  42785. * Fires when the reference space changed
  42786. */
  42787. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42788. /**
  42789. * Fires when the xr session is ended either by the device or manually done
  42790. */
  42791. onXRSessionEnded: Observable<any>;
  42792. /**
  42793. * Fires when the xr session is ended either by the device or manually done
  42794. */
  42795. onXRSessionInit: Observable<XRSession>;
  42796. /**
  42797. * Underlying xr session
  42798. */
  42799. session: XRSession;
  42800. /**
  42801. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42802. * or get the offset the player is currently at.
  42803. */
  42804. viewerReferenceSpace: XRReferenceSpace;
  42805. /**
  42806. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42807. * @param scene The scene which the session should be created for
  42808. */
  42809. constructor(
  42810. /** The scene which the session should be created for */
  42811. scene: Scene);
  42812. /**
  42813. * The current reference space used in this session. This reference space can constantly change!
  42814. * It is mainly used to offset the camera's position.
  42815. */
  42816. get referenceSpace(): XRReferenceSpace;
  42817. /**
  42818. * Set a new reference space and triggers the observable
  42819. */
  42820. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42821. /**
  42822. * Disposes of the session manager
  42823. */
  42824. dispose(): void;
  42825. /**
  42826. * Stops the xrSession and restores the render loop
  42827. * @returns Promise which resolves after it exits XR
  42828. */
  42829. exitXRAsync(): Promise<void>;
  42830. /**
  42831. * Gets the correct render target texture to be rendered this frame for this eye
  42832. * @param eye the eye for which to get the render target
  42833. * @returns the render target for the specified eye
  42834. */
  42835. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42836. /**
  42837. * Creates a WebXRRenderTarget object for the XR session
  42838. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42839. * @param options optional options to provide when creating a new render target
  42840. * @returns a WebXR render target to which the session can render
  42841. */
  42842. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42843. /**
  42844. * Initializes the manager
  42845. * After initialization enterXR can be called to start an XR session
  42846. * @returns Promise which resolves after it is initialized
  42847. */
  42848. initializeAsync(): Promise<void>;
  42849. /**
  42850. * Initializes an xr session
  42851. * @param xrSessionMode mode to initialize
  42852. * @param xrSessionInit defines optional and required values to pass to the session builder
  42853. * @returns a promise which will resolve once the session has been initialized
  42854. */
  42855. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42856. /**
  42857. * Checks if a session would be supported for the creation options specified
  42858. * @param sessionMode session mode to check if supported eg. immersive-vr
  42859. * @returns A Promise that resolves to true if supported and false if not
  42860. */
  42861. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42862. /**
  42863. * Resets the reference space to the one started the session
  42864. */
  42865. resetReferenceSpace(): void;
  42866. /**
  42867. * Starts rendering to the xr layer
  42868. */
  42869. runXRRenderLoop(): void;
  42870. /**
  42871. * Sets the reference space on the xr session
  42872. * @param referenceSpaceType space to set
  42873. * @returns a promise that will resolve once the reference space has been set
  42874. */
  42875. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42876. /**
  42877. * Updates the render state of the session
  42878. * @param state state to set
  42879. * @returns a promise that resolves once the render state has been updated
  42880. */
  42881. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42882. /**
  42883. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42884. * @param sessionMode defines the session to test
  42885. * @returns a promise with boolean as final value
  42886. */
  42887. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42888. private _createRenderTargetTexture;
  42889. }
  42890. }
  42891. declare module BABYLON {
  42892. /**
  42893. * WebXR Camera which holds the views for the xrSession
  42894. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42895. */
  42896. export class WebXRCamera extends FreeCamera {
  42897. private _xrSessionManager;
  42898. private _firstFrame;
  42899. private _referenceQuaternion;
  42900. private _referencedPosition;
  42901. private _xrInvPositionCache;
  42902. private _xrInvQuaternionCache;
  42903. /**
  42904. * Should position compensation execute on first frame.
  42905. * This is used when copying the position from a native (non XR) camera
  42906. */
  42907. compensateOnFirstFrame: boolean;
  42908. /**
  42909. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42910. * @param name the name of the camera
  42911. * @param scene the scene to add the camera to
  42912. * @param _xrSessionManager a constructed xr session manager
  42913. */
  42914. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42915. /**
  42916. * Return the user's height, unrelated to the current ground.
  42917. * This will be the y position of this camera, when ground level is 0.
  42918. */
  42919. get realWorldHeight(): number;
  42920. /** @hidden */
  42921. _updateForDualEyeDebugging(): void;
  42922. /**
  42923. * Sets this camera's transformation based on a non-vr camera
  42924. * @param otherCamera the non-vr camera to copy the transformation from
  42925. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42926. */
  42927. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42928. /**
  42929. * Gets the current instance class name ("WebXRCamera").
  42930. * @returns the class name
  42931. */
  42932. getClassName(): string;
  42933. private _updateFromXRSession;
  42934. private _updateNumberOfRigCameras;
  42935. private _updateReferenceSpace;
  42936. private _updateReferenceSpaceOffset;
  42937. }
  42938. }
  42939. declare module BABYLON {
  42940. /**
  42941. * Defining the interface required for a (webxr) feature
  42942. */
  42943. export interface IWebXRFeature extends IDisposable {
  42944. /**
  42945. * Is this feature attached
  42946. */
  42947. attached: boolean;
  42948. /**
  42949. * Should auto-attach be disabled?
  42950. */
  42951. disableAutoAttach: boolean;
  42952. /**
  42953. * Attach the feature to the session
  42954. * Will usually be called by the features manager
  42955. *
  42956. * @param force should attachment be forced (even when already attached)
  42957. * @returns true if successful.
  42958. */
  42959. attach(force?: boolean): boolean;
  42960. /**
  42961. * Detach the feature from the session
  42962. * Will usually be called by the features manager
  42963. *
  42964. * @returns true if successful.
  42965. */
  42966. detach(): boolean;
  42967. }
  42968. /**
  42969. * A list of the currently available features without referencing them
  42970. */
  42971. export class WebXRFeatureName {
  42972. /**
  42973. * The name of the anchor system feature
  42974. */
  42975. static ANCHOR_SYSTEM: string;
  42976. /**
  42977. * The name of the background remover feature
  42978. */
  42979. static BACKGROUND_REMOVER: string;
  42980. /**
  42981. * The name of the hit test feature
  42982. */
  42983. static HIT_TEST: string;
  42984. /**
  42985. * physics impostors for xr controllers feature
  42986. */
  42987. static PHYSICS_CONTROLLERS: string;
  42988. /**
  42989. * The name of the plane detection feature
  42990. */
  42991. static PLANE_DETECTION: string;
  42992. /**
  42993. * The name of the pointer selection feature
  42994. */
  42995. static POINTER_SELECTION: string;
  42996. /**
  42997. * The name of the teleportation feature
  42998. */
  42999. static TELEPORTATION: string;
  43000. }
  43001. /**
  43002. * Defining the constructor of a feature. Used to register the modules.
  43003. */
  43004. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43005. /**
  43006. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43007. * It is mainly used in AR sessions.
  43008. *
  43009. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43010. */
  43011. export class WebXRFeaturesManager implements IDisposable {
  43012. private _xrSessionManager;
  43013. private static readonly _AvailableFeatures;
  43014. private _features;
  43015. /**
  43016. * constructs a new features manages.
  43017. *
  43018. * @param _xrSessionManager an instance of WebXRSessionManager
  43019. */
  43020. constructor(_xrSessionManager: WebXRSessionManager);
  43021. /**
  43022. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43023. * Mainly used internally.
  43024. *
  43025. * @param featureName the name of the feature to register
  43026. * @param constructorFunction the function used to construct the module
  43027. * @param version the (babylon) version of the module
  43028. * @param stable is that a stable version of this module
  43029. */
  43030. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43031. /**
  43032. * Returns a constructor of a specific feature.
  43033. *
  43034. * @param featureName the name of the feature to construct
  43035. * @param version the version of the feature to load
  43036. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43037. * @param options optional options provided to the module.
  43038. * @returns a function that, when called, will return a new instance of this feature
  43039. */
  43040. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43041. /**
  43042. * Can be used to return the list of features currently registered
  43043. *
  43044. * @returns an Array of available features
  43045. */
  43046. static GetAvailableFeatures(): string[];
  43047. /**
  43048. * Gets the versions available for a specific feature
  43049. * @param featureName the name of the feature
  43050. * @returns an array with the available versions
  43051. */
  43052. static GetAvailableVersions(featureName: string): string[];
  43053. /**
  43054. * Return the latest unstable version of this feature
  43055. * @param featureName the name of the feature to search
  43056. * @returns the version number. if not found will return -1
  43057. */
  43058. static GetLatestVersionOfFeature(featureName: string): number;
  43059. /**
  43060. * Return the latest stable version of this feature
  43061. * @param featureName the name of the feature to search
  43062. * @returns the version number. if not found will return -1
  43063. */
  43064. static GetStableVersionOfFeature(featureName: string): number;
  43065. /**
  43066. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43067. * Can be used during a session to start a feature
  43068. * @param featureName the name of feature to attach
  43069. */
  43070. attachFeature(featureName: string): void;
  43071. /**
  43072. * Can be used inside a session or when the session ends to detach a specific feature
  43073. * @param featureName the name of the feature to detach
  43074. */
  43075. detachFeature(featureName: string): void;
  43076. /**
  43077. * Used to disable an already-enabled feature
  43078. * The feature will be disposed and will be recreated once enabled.
  43079. * @param featureName the feature to disable
  43080. * @returns true if disable was successful
  43081. */
  43082. disableFeature(featureName: string | {
  43083. Name: string;
  43084. }): boolean;
  43085. /**
  43086. * dispose this features manager
  43087. */
  43088. dispose(): void;
  43089. /**
  43090. * 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.
  43091. * 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.
  43092. *
  43093. * @param featureName the name of the feature to load or the class of the feature
  43094. * @param version optional version to load. if not provided the latest version will be enabled
  43095. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43096. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43097. * @returns a new constructed feature or throws an error if feature not found.
  43098. */
  43099. enableFeature(featureName: string | {
  43100. Name: string;
  43101. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43102. /**
  43103. * get the implementation of an enabled feature.
  43104. * @param featureName the name of the feature to load
  43105. * @returns the feature class, if found
  43106. */
  43107. getEnabledFeature(featureName: string): IWebXRFeature;
  43108. /**
  43109. * Get the list of enabled features
  43110. * @returns an array of enabled features
  43111. */
  43112. getEnabledFeatures(): string[];
  43113. }
  43114. }
  43115. declare module BABYLON {
  43116. /**
  43117. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43118. * @see https://doc.babylonjs.com/how_to/webxr
  43119. */
  43120. export class WebXRExperienceHelper implements IDisposable {
  43121. private scene;
  43122. private _nonVRCamera;
  43123. private _originalSceneAutoClear;
  43124. private _supported;
  43125. /**
  43126. * Camera used to render xr content
  43127. */
  43128. camera: WebXRCamera;
  43129. /** A features manager for this xr session */
  43130. featuresManager: WebXRFeaturesManager;
  43131. /**
  43132. * Observers registered here will be triggered after the camera's initial transformation is set
  43133. * This can be used to set a different ground level or an extra rotation.
  43134. *
  43135. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43136. * to the position set after this observable is done executing.
  43137. */
  43138. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43139. /**
  43140. * Fires when the state of the experience helper has changed
  43141. */
  43142. onStateChangedObservable: Observable<WebXRState>;
  43143. /** Session manager used to keep track of xr session */
  43144. sessionManager: WebXRSessionManager;
  43145. /**
  43146. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43147. */
  43148. state: WebXRState;
  43149. /**
  43150. * Creates a WebXRExperienceHelper
  43151. * @param scene The scene the helper should be created in
  43152. */
  43153. private constructor();
  43154. /**
  43155. * Creates the experience helper
  43156. * @param scene the scene to attach the experience helper to
  43157. * @returns a promise for the experience helper
  43158. */
  43159. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43160. /**
  43161. * Disposes of the experience helper
  43162. */
  43163. dispose(): void;
  43164. /**
  43165. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43166. * @param sessionMode options for the XR session
  43167. * @param referenceSpaceType frame of reference of the XR session
  43168. * @param renderTarget the output canvas that will be used to enter XR mode
  43169. * @returns promise that resolves after xr mode has entered
  43170. */
  43171. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43172. /**
  43173. * Exits XR mode and returns the scene to its original state
  43174. * @returns promise that resolves after xr mode has exited
  43175. */
  43176. exitXRAsync(): Promise<void>;
  43177. private _nonXRToXRCamera;
  43178. private _setState;
  43179. }
  43180. }
  43181. declare module BABYLON {
  43182. /**
  43183. * X-Y values for axes in WebXR
  43184. */
  43185. export interface IWebXRMotionControllerAxesValue {
  43186. /**
  43187. * The value of the x axis
  43188. */
  43189. x: number;
  43190. /**
  43191. * The value of the y-axis
  43192. */
  43193. y: number;
  43194. }
  43195. /**
  43196. * changed / previous values for the values of this component
  43197. */
  43198. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43199. /**
  43200. * current (this frame) value
  43201. */
  43202. current: T;
  43203. /**
  43204. * previous (last change) value
  43205. */
  43206. previous: T;
  43207. }
  43208. /**
  43209. * Represents changes in the component between current frame and last values recorded
  43210. */
  43211. export interface IWebXRMotionControllerComponentChanges {
  43212. /**
  43213. * will be populated with previous and current values if axes changed
  43214. */
  43215. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43216. /**
  43217. * will be populated with previous and current values if pressed changed
  43218. */
  43219. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43220. /**
  43221. * will be populated with previous and current values if touched changed
  43222. */
  43223. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43224. /**
  43225. * will be populated with previous and current values if value changed
  43226. */
  43227. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43228. }
  43229. /**
  43230. * This class represents a single component (for example button or thumbstick) of a motion controller
  43231. */
  43232. export class WebXRControllerComponent implements IDisposable {
  43233. /**
  43234. * the id of this component
  43235. */
  43236. id: string;
  43237. /**
  43238. * the type of the component
  43239. */
  43240. type: MotionControllerComponentType;
  43241. private _buttonIndex;
  43242. private _axesIndices;
  43243. private _axes;
  43244. private _changes;
  43245. private _currentValue;
  43246. private _hasChanges;
  43247. private _pressed;
  43248. private _touched;
  43249. /**
  43250. * button component type
  43251. */
  43252. static BUTTON_TYPE: MotionControllerComponentType;
  43253. /**
  43254. * squeeze component type
  43255. */
  43256. static SQUEEZE_TYPE: MotionControllerComponentType;
  43257. /**
  43258. * Thumbstick component type
  43259. */
  43260. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43261. /**
  43262. * Touchpad component type
  43263. */
  43264. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43265. /**
  43266. * trigger component type
  43267. */
  43268. static TRIGGER_TYPE: MotionControllerComponentType;
  43269. /**
  43270. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43271. * the axes data changes
  43272. */
  43273. onAxisValueChangedObservable: Observable<{
  43274. x: number;
  43275. y: number;
  43276. }>;
  43277. /**
  43278. * Observers registered here will be triggered when the state of a button changes
  43279. * State change is either pressed / touched / value
  43280. */
  43281. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43282. /**
  43283. * Creates a new component for a motion controller.
  43284. * It is created by the motion controller itself
  43285. *
  43286. * @param id the id of this component
  43287. * @param type the type of the component
  43288. * @param _buttonIndex index in the buttons array of the gamepad
  43289. * @param _axesIndices indices of the values in the axes array of the gamepad
  43290. */
  43291. constructor(
  43292. /**
  43293. * the id of this component
  43294. */
  43295. id: string,
  43296. /**
  43297. * the type of the component
  43298. */
  43299. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43300. /**
  43301. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43302. */
  43303. get axes(): IWebXRMotionControllerAxesValue;
  43304. /**
  43305. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43306. */
  43307. get changes(): IWebXRMotionControllerComponentChanges;
  43308. /**
  43309. * Return whether or not the component changed the last frame
  43310. */
  43311. get hasChanges(): boolean;
  43312. /**
  43313. * is the button currently pressed
  43314. */
  43315. get pressed(): boolean;
  43316. /**
  43317. * is the button currently touched
  43318. */
  43319. get touched(): boolean;
  43320. /**
  43321. * Get the current value of this component
  43322. */
  43323. get value(): number;
  43324. /**
  43325. * Dispose this component
  43326. */
  43327. dispose(): void;
  43328. /**
  43329. * Are there axes correlating to this component
  43330. * @return true is axes data is available
  43331. */
  43332. isAxes(): boolean;
  43333. /**
  43334. * Is this component a button (hence - pressable)
  43335. * @returns true if can be pressed
  43336. */
  43337. isButton(): boolean;
  43338. /**
  43339. * update this component using the gamepad object it is in. Called on every frame
  43340. * @param nativeController the native gamepad controller object
  43341. */
  43342. update(nativeController: IMinimalMotionControllerObject): void;
  43343. }
  43344. }
  43345. declare module BABYLON {
  43346. /**
  43347. * Class used to represent data loading progression
  43348. */
  43349. export class SceneLoaderProgressEvent {
  43350. /** defines if data length to load can be evaluated */
  43351. readonly lengthComputable: boolean;
  43352. /** defines the loaded data length */
  43353. readonly loaded: number;
  43354. /** defines the data length to load */
  43355. readonly total: number;
  43356. /**
  43357. * Create a new progress event
  43358. * @param lengthComputable defines if data length to load can be evaluated
  43359. * @param loaded defines the loaded data length
  43360. * @param total defines the data length to load
  43361. */
  43362. constructor(
  43363. /** defines if data length to load can be evaluated */
  43364. lengthComputable: boolean,
  43365. /** defines the loaded data length */
  43366. loaded: number,
  43367. /** defines the data length to load */
  43368. total: number);
  43369. /**
  43370. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43371. * @param event defines the source event
  43372. * @returns a new SceneLoaderProgressEvent
  43373. */
  43374. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43375. }
  43376. /**
  43377. * Interface used by SceneLoader plugins to define supported file extensions
  43378. */
  43379. export interface ISceneLoaderPluginExtensions {
  43380. /**
  43381. * Defines the list of supported extensions
  43382. */
  43383. [extension: string]: {
  43384. isBinary: boolean;
  43385. };
  43386. }
  43387. /**
  43388. * Interface used by SceneLoader plugin factory
  43389. */
  43390. export interface ISceneLoaderPluginFactory {
  43391. /**
  43392. * Defines the name of the factory
  43393. */
  43394. name: string;
  43395. /**
  43396. * Function called to create a new plugin
  43397. * @return the new plugin
  43398. */
  43399. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43400. /**
  43401. * The callback that returns true if the data can be directly loaded.
  43402. * @param data string containing the file data
  43403. * @returns if the data can be loaded directly
  43404. */
  43405. canDirectLoad?(data: string): boolean;
  43406. }
  43407. /**
  43408. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43409. */
  43410. export interface ISceneLoaderPluginBase {
  43411. /**
  43412. * The friendly name of this plugin.
  43413. */
  43414. name: string;
  43415. /**
  43416. * The file extensions supported by this plugin.
  43417. */
  43418. extensions: string | ISceneLoaderPluginExtensions;
  43419. /**
  43420. * The callback called when loading from a url.
  43421. * @param scene scene loading this url
  43422. * @param url url to load
  43423. * @param onSuccess callback called when the file successfully loads
  43424. * @param onProgress callback called while file is loading (if the server supports this mode)
  43425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43426. * @param onError callback called when the file fails to load
  43427. * @returns a file request object
  43428. */
  43429. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43430. /**
  43431. * The callback called when loading from a file object.
  43432. * @param scene scene loading this file
  43433. * @param file defines the file to load
  43434. * @param onSuccess defines the callback to call when data is loaded
  43435. * @param onProgress defines the callback to call during loading process
  43436. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43437. * @param onError defines the callback to call when an error occurs
  43438. * @returns a file request object
  43439. */
  43440. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43441. /**
  43442. * The callback that returns true if the data can be directly loaded.
  43443. * @param data string containing the file data
  43444. * @returns if the data can be loaded directly
  43445. */
  43446. canDirectLoad?(data: string): boolean;
  43447. /**
  43448. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43449. * @param scene scene loading this data
  43450. * @param data string containing the data
  43451. * @returns data to pass to the plugin
  43452. */
  43453. directLoad?(scene: Scene, data: string): any;
  43454. /**
  43455. * The callback that allows custom handling of the root url based on the response url.
  43456. * @param rootUrl the original root url
  43457. * @param responseURL the response url if available
  43458. * @returns the new root url
  43459. */
  43460. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43461. }
  43462. /**
  43463. * Interface used to define a SceneLoader plugin
  43464. */
  43465. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43466. /**
  43467. * Import meshes into a scene.
  43468. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43469. * @param scene The scene to import into
  43470. * @param data The data to import
  43471. * @param rootUrl The root url for scene and resources
  43472. * @param meshes The meshes array to import into
  43473. * @param particleSystems The particle systems array to import into
  43474. * @param skeletons The skeletons array to import into
  43475. * @param onError The callback when import fails
  43476. * @returns True if successful or false otherwise
  43477. */
  43478. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43479. /**
  43480. * Load into a scene.
  43481. * @param scene The scene to load into
  43482. * @param data The data to import
  43483. * @param rootUrl The root url for scene and resources
  43484. * @param onError The callback when import fails
  43485. * @returns True if successful or false otherwise
  43486. */
  43487. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43488. /**
  43489. * Load into an asset container.
  43490. * @param scene The scene to load into
  43491. * @param data The data to import
  43492. * @param rootUrl The root url for scene and resources
  43493. * @param onError The callback when import fails
  43494. * @returns The loaded asset container
  43495. */
  43496. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43497. }
  43498. /**
  43499. * Interface used to define an async SceneLoader plugin
  43500. */
  43501. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43502. /**
  43503. * Import meshes into a scene.
  43504. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43505. * @param scene The scene to import into
  43506. * @param data The data to import
  43507. * @param rootUrl The root url for scene and resources
  43508. * @param onProgress The callback when the load progresses
  43509. * @param fileName Defines the name of the file to load
  43510. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43511. */
  43512. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43513. meshes: AbstractMesh[];
  43514. particleSystems: IParticleSystem[];
  43515. skeletons: Skeleton[];
  43516. animationGroups: AnimationGroup[];
  43517. }>;
  43518. /**
  43519. * Load into a scene.
  43520. * @param scene The scene to load into
  43521. * @param data The data to import
  43522. * @param rootUrl The root url for scene and resources
  43523. * @param onProgress The callback when the load progresses
  43524. * @param fileName Defines the name of the file to load
  43525. * @returns Nothing
  43526. */
  43527. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43528. /**
  43529. * Load into an asset container.
  43530. * @param scene The scene to load into
  43531. * @param data The data to import
  43532. * @param rootUrl The root url for scene and resources
  43533. * @param onProgress The callback when the load progresses
  43534. * @param fileName Defines the name of the file to load
  43535. * @returns The loaded asset container
  43536. */
  43537. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43538. }
  43539. /**
  43540. * Mode that determines how to handle old animation groups before loading new ones.
  43541. */
  43542. export enum SceneLoaderAnimationGroupLoadingMode {
  43543. /**
  43544. * Reset all old animations to initial state then dispose them.
  43545. */
  43546. Clean = 0,
  43547. /**
  43548. * Stop all old animations.
  43549. */
  43550. Stop = 1,
  43551. /**
  43552. * Restart old animations from first frame.
  43553. */
  43554. Sync = 2,
  43555. /**
  43556. * Old animations remains untouched.
  43557. */
  43558. NoSync = 3
  43559. }
  43560. /**
  43561. * Class used to load scene from various file formats using registered plugins
  43562. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43563. */
  43564. export class SceneLoader {
  43565. /**
  43566. * No logging while loading
  43567. */
  43568. static readonly NO_LOGGING: number;
  43569. /**
  43570. * Minimal logging while loading
  43571. */
  43572. static readonly MINIMAL_LOGGING: number;
  43573. /**
  43574. * Summary logging while loading
  43575. */
  43576. static readonly SUMMARY_LOGGING: number;
  43577. /**
  43578. * Detailled logging while loading
  43579. */
  43580. static readonly DETAILED_LOGGING: number;
  43581. /**
  43582. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43583. */
  43584. static get ForceFullSceneLoadingForIncremental(): boolean;
  43585. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43586. /**
  43587. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43588. */
  43589. static get ShowLoadingScreen(): boolean;
  43590. static set ShowLoadingScreen(value: boolean);
  43591. /**
  43592. * Defines the current logging level (while loading the scene)
  43593. * @ignorenaming
  43594. */
  43595. static get loggingLevel(): number;
  43596. static set loggingLevel(value: number);
  43597. /**
  43598. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43599. */
  43600. static get CleanBoneMatrixWeights(): boolean;
  43601. static set CleanBoneMatrixWeights(value: boolean);
  43602. /**
  43603. * Event raised when a plugin is used to load a scene
  43604. */
  43605. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43606. private static _registeredPlugins;
  43607. private static _getDefaultPlugin;
  43608. private static _getPluginForExtension;
  43609. private static _getPluginForDirectLoad;
  43610. private static _getPluginForFilename;
  43611. private static _getDirectLoad;
  43612. private static _loadData;
  43613. private static _getFileInfo;
  43614. /**
  43615. * Gets a plugin that can load the given extension
  43616. * @param extension defines the extension to load
  43617. * @returns a plugin or null if none works
  43618. */
  43619. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43620. /**
  43621. * Gets a boolean indicating that the given extension can be loaded
  43622. * @param extension defines the extension to load
  43623. * @returns true if the extension is supported
  43624. */
  43625. static IsPluginForExtensionAvailable(extension: string): boolean;
  43626. /**
  43627. * Adds a new plugin to the list of registered plugins
  43628. * @param plugin defines the plugin to add
  43629. */
  43630. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43631. /**
  43632. * Import meshes into a scene
  43633. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43634. * @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)
  43635. * @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)
  43636. * @param scene the instance of BABYLON.Scene to append to
  43637. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43638. * @param onProgress a callback with a progress event for each file being loaded
  43639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43640. * @param pluginExtension the extension used to determine the plugin
  43641. * @returns The loaded plugin
  43642. */
  43643. 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>;
  43644. /**
  43645. * Import meshes into a scene
  43646. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43647. * @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)
  43648. * @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)
  43649. * @param scene the instance of BABYLON.Scene to append to
  43650. * @param onProgress a callback with a progress event for each file being loaded
  43651. * @param pluginExtension the extension used to determine the plugin
  43652. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43653. */
  43654. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43655. meshes: AbstractMesh[];
  43656. particleSystems: IParticleSystem[];
  43657. skeletons: Skeleton[];
  43658. animationGroups: AnimationGroup[];
  43659. }>;
  43660. /**
  43661. * Load a scene
  43662. * @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)
  43663. * @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)
  43664. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43665. * @param onSuccess a callback with the scene when import succeeds
  43666. * @param onProgress a callback with a progress event for each file being loaded
  43667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43668. * @param pluginExtension the extension used to determine the plugin
  43669. * @returns The loaded plugin
  43670. */
  43671. 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>;
  43672. /**
  43673. * Load a scene
  43674. * @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)
  43675. * @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)
  43676. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43677. * @param onProgress a callback with a progress event for each file being loaded
  43678. * @param pluginExtension the extension used to determine the plugin
  43679. * @returns The loaded scene
  43680. */
  43681. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43682. /**
  43683. * Append a scene
  43684. * @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)
  43685. * @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)
  43686. * @param scene is the instance of BABYLON.Scene to append to
  43687. * @param onSuccess a callback with the scene when import succeeds
  43688. * @param onProgress a callback with a progress event for each file being loaded
  43689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43690. * @param pluginExtension the extension used to determine the plugin
  43691. * @returns The loaded plugin
  43692. */
  43693. 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>;
  43694. /**
  43695. * Append a scene
  43696. * @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)
  43697. * @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)
  43698. * @param scene is the instance of BABYLON.Scene to append to
  43699. * @param onProgress a callback with a progress event for each file being loaded
  43700. * @param pluginExtension the extension used to determine the plugin
  43701. * @returns The given scene
  43702. */
  43703. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43704. /**
  43705. * Load a scene into an asset container
  43706. * @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)
  43707. * @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)
  43708. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43709. * @param onSuccess a callback with the scene when import succeeds
  43710. * @param onProgress a callback with a progress event for each file being loaded
  43711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43712. * @param pluginExtension the extension used to determine the plugin
  43713. * @returns The loaded plugin
  43714. */
  43715. 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>;
  43716. /**
  43717. * Load a scene into an asset container
  43718. * @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)
  43719. * @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)
  43720. * @param scene is the instance of Scene to append to
  43721. * @param onProgress a callback with a progress event for each file being loaded
  43722. * @param pluginExtension the extension used to determine the plugin
  43723. * @returns The loaded asset container
  43724. */
  43725. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43726. /**
  43727. * Import animations from a file into a scene
  43728. * @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)
  43729. * @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)
  43730. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43731. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43732. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43733. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43734. * @param onSuccess a callback with the scene when import succeeds
  43735. * @param onProgress a callback with a progress event for each file being loaded
  43736. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43737. */
  43738. 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;
  43739. /**
  43740. * Import animations from a file into a scene
  43741. * @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)
  43742. * @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)
  43743. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43744. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43745. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43746. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43747. * @param onSuccess a callback with the scene when import succeeds
  43748. * @param onProgress a callback with a progress event for each file being loaded
  43749. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43750. * @returns the updated scene with imported animations
  43751. */
  43752. 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>;
  43753. }
  43754. }
  43755. declare module BABYLON {
  43756. /**
  43757. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43758. */
  43759. export type MotionControllerHandness = "none" | "left" | "right";
  43760. /**
  43761. * The type of components available in motion controllers.
  43762. * This is not the name of the component.
  43763. */
  43764. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43765. /**
  43766. * The state of a controller component
  43767. */
  43768. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43769. /**
  43770. * The schema of motion controller layout.
  43771. * No object will be initialized using this interface
  43772. * This is used just to define the profile.
  43773. */
  43774. export interface IMotionControllerLayout {
  43775. /**
  43776. * Path to load the assets. Usually relative to the base path
  43777. */
  43778. assetPath: string;
  43779. /**
  43780. * Available components (unsorted)
  43781. */
  43782. components: {
  43783. /**
  43784. * A map of component Ids
  43785. */
  43786. [componentId: string]: {
  43787. /**
  43788. * The type of input the component outputs
  43789. */
  43790. type: MotionControllerComponentType;
  43791. /**
  43792. * The indices of this component in the gamepad object
  43793. */
  43794. gamepadIndices: {
  43795. /**
  43796. * Index of button
  43797. */
  43798. button?: number;
  43799. /**
  43800. * If available, index of x-axis
  43801. */
  43802. xAxis?: number;
  43803. /**
  43804. * If available, index of y-axis
  43805. */
  43806. yAxis?: number;
  43807. };
  43808. /**
  43809. * The mesh's root node name
  43810. */
  43811. rootNodeName: string;
  43812. /**
  43813. * Animation definitions for this model
  43814. */
  43815. visualResponses: {
  43816. [stateKey: string]: {
  43817. /**
  43818. * What property will be animated
  43819. */
  43820. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43821. /**
  43822. * What states influence this visual response
  43823. */
  43824. states: MotionControllerComponentStateType[];
  43825. /**
  43826. * Type of animation - movement or visibility
  43827. */
  43828. valueNodeProperty: "transform" | "visibility";
  43829. /**
  43830. * Base node name to move. Its position will be calculated according to the min and max nodes
  43831. */
  43832. valueNodeName?: string;
  43833. /**
  43834. * Minimum movement node
  43835. */
  43836. minNodeName?: string;
  43837. /**
  43838. * Max movement node
  43839. */
  43840. maxNodeName?: string;
  43841. };
  43842. };
  43843. /**
  43844. * If touch enabled, what is the name of node to display user feedback
  43845. */
  43846. touchPointNodeName?: string;
  43847. };
  43848. };
  43849. /**
  43850. * Is it xr standard mapping or not
  43851. */
  43852. gamepadMapping: "" | "xr-standard";
  43853. /**
  43854. * Base root node of this entire model
  43855. */
  43856. rootNodeName: string;
  43857. /**
  43858. * Defines the main button component id
  43859. */
  43860. selectComponentId: string;
  43861. }
  43862. /**
  43863. * A definition for the layout map in the input profile
  43864. */
  43865. export interface IMotionControllerLayoutMap {
  43866. /**
  43867. * Layouts with handness type as a key
  43868. */
  43869. [handness: string]: IMotionControllerLayout;
  43870. }
  43871. /**
  43872. * The XR Input profile schema
  43873. * Profiles can be found here:
  43874. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43875. */
  43876. export interface IMotionControllerProfile {
  43877. /**
  43878. * fallback profiles for this profileId
  43879. */
  43880. fallbackProfileIds: string[];
  43881. /**
  43882. * The layout map, with handness as key
  43883. */
  43884. layouts: IMotionControllerLayoutMap;
  43885. /**
  43886. * The id of this profile
  43887. * correlates to the profile(s) in the xrInput.profiles array
  43888. */
  43889. profileId: string;
  43890. }
  43891. /**
  43892. * A helper-interface for the 3 meshes needed for controller button animation
  43893. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43894. */
  43895. export interface IMotionControllerButtonMeshMap {
  43896. /**
  43897. * the mesh that defines the pressed value mesh position.
  43898. * This is used to find the max-position of this button
  43899. */
  43900. pressedMesh: AbstractMesh;
  43901. /**
  43902. * the mesh that defines the unpressed value mesh position.
  43903. * This is used to find the min (or initial) position of this button
  43904. */
  43905. unpressedMesh: AbstractMesh;
  43906. /**
  43907. * The mesh that will be changed when value changes
  43908. */
  43909. valueMesh: AbstractMesh;
  43910. }
  43911. /**
  43912. * A helper-interface for the 3 meshes needed for controller axis animation.
  43913. * This will be expanded when touchpad animations are fully supported
  43914. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43915. */
  43916. export interface IMotionControllerMeshMap {
  43917. /**
  43918. * the mesh that defines the maximum value mesh position.
  43919. */
  43920. maxMesh?: AbstractMesh;
  43921. /**
  43922. * the mesh that defines the minimum value mesh position.
  43923. */
  43924. minMesh?: AbstractMesh;
  43925. /**
  43926. * The mesh that will be changed when axis value changes
  43927. */
  43928. valueMesh: AbstractMesh;
  43929. }
  43930. /**
  43931. * The elements needed for change-detection of the gamepad objects in motion controllers
  43932. */
  43933. export interface IMinimalMotionControllerObject {
  43934. /**
  43935. * Available axes of this controller
  43936. */
  43937. axes: number[];
  43938. /**
  43939. * An array of available buttons
  43940. */
  43941. buttons: Array<{
  43942. /**
  43943. * Value of the button/trigger
  43944. */
  43945. value: number;
  43946. /**
  43947. * If the button/trigger is currently touched
  43948. */
  43949. touched: boolean;
  43950. /**
  43951. * If the button/trigger is currently pressed
  43952. */
  43953. pressed: boolean;
  43954. }>;
  43955. }
  43956. /**
  43957. * An Abstract Motion controller
  43958. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43959. * Each component has an observable to check for changes in value and state
  43960. */
  43961. export abstract class WebXRAbstractMotionController implements IDisposable {
  43962. protected scene: Scene;
  43963. protected layout: IMotionControllerLayout;
  43964. /**
  43965. * The gamepad object correlating to this controller
  43966. */
  43967. gamepadObject: IMinimalMotionControllerObject;
  43968. /**
  43969. * handness (left/right/none) of this controller
  43970. */
  43971. handness: MotionControllerHandness;
  43972. private _initComponent;
  43973. private _modelReady;
  43974. /**
  43975. * A map of components (WebXRControllerComponent) in this motion controller
  43976. * Components have a ComponentType and can also have both button and axis definitions
  43977. */
  43978. readonly components: {
  43979. [id: string]: WebXRControllerComponent;
  43980. };
  43981. /**
  43982. * Disable the model's animation. Can be set at any time.
  43983. */
  43984. disableAnimation: boolean;
  43985. /**
  43986. * Observers registered here will be triggered when the model of this controller is done loading
  43987. */
  43988. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43989. /**
  43990. * The profile id of this motion controller
  43991. */
  43992. abstract profileId: string;
  43993. /**
  43994. * The root mesh of the model. It is null if the model was not yet initialized
  43995. */
  43996. rootMesh: Nullable<AbstractMesh>;
  43997. /**
  43998. * constructs a new abstract motion controller
  43999. * @param scene the scene to which the model of the controller will be added
  44000. * @param layout The profile layout to load
  44001. * @param gamepadObject The gamepad object correlating to this controller
  44002. * @param handness handness (left/right/none) of this controller
  44003. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44004. */
  44005. constructor(scene: Scene, layout: IMotionControllerLayout,
  44006. /**
  44007. * The gamepad object correlating to this controller
  44008. */
  44009. gamepadObject: IMinimalMotionControllerObject,
  44010. /**
  44011. * handness (left/right/none) of this controller
  44012. */
  44013. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44014. /**
  44015. * Dispose this controller, the model mesh and all its components
  44016. */
  44017. dispose(): void;
  44018. /**
  44019. * Returns all components of specific type
  44020. * @param type the type to search for
  44021. * @return an array of components with this type
  44022. */
  44023. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44024. /**
  44025. * get a component based an its component id as defined in layout.components
  44026. * @param id the id of the component
  44027. * @returns the component correlates to the id or undefined if not found
  44028. */
  44029. getComponent(id: string): WebXRControllerComponent;
  44030. /**
  44031. * Get the list of components available in this motion controller
  44032. * @returns an array of strings correlating to available components
  44033. */
  44034. getComponentIds(): string[];
  44035. /**
  44036. * Get the first component of specific type
  44037. * @param type type of component to find
  44038. * @return a controller component or null if not found
  44039. */
  44040. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44041. /**
  44042. * Get the main (Select) component of this controller as defined in the layout
  44043. * @returns the main component of this controller
  44044. */
  44045. getMainComponent(): WebXRControllerComponent;
  44046. /**
  44047. * Loads the model correlating to this controller
  44048. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44049. * @returns A promise fulfilled with the result of the model loading
  44050. */
  44051. loadModel(): Promise<boolean>;
  44052. /**
  44053. * Update this model using the current XRFrame
  44054. * @param xrFrame the current xr frame to use and update the model
  44055. */
  44056. updateFromXRFrame(xrFrame: XRFrame): void;
  44057. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44058. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44059. /**
  44060. * Moves the axis on the controller mesh based on its current state
  44061. * @param axis the index of the axis
  44062. * @param axisValue the value of the axis which determines the meshes new position
  44063. * @hidden
  44064. */
  44065. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44066. /**
  44067. * Update the model itself with the current frame data
  44068. * @param xrFrame the frame to use for updating the model mesh
  44069. */
  44070. protected updateModel(xrFrame: XRFrame): void;
  44071. /**
  44072. * Get the filename and path for this controller's model
  44073. * @returns a map of filename and path
  44074. */
  44075. protected abstract _getFilenameAndPath(): {
  44076. filename: string;
  44077. path: string;
  44078. };
  44079. /**
  44080. * This function is called before the mesh is loaded. It checks for loading constraints.
  44081. * For example, this function can check if the GLB loader is available
  44082. * If this function returns false, the generic controller will be loaded instead
  44083. * @returns Is the client ready to load the mesh
  44084. */
  44085. protected abstract _getModelLoadingConstraints(): boolean;
  44086. /**
  44087. * This function will be called after the model was successfully loaded and can be used
  44088. * for mesh transformations before it is available for the user
  44089. * @param meshes the loaded meshes
  44090. */
  44091. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44092. /**
  44093. * Set the root mesh for this controller. Important for the WebXR controller class
  44094. * @param meshes the loaded meshes
  44095. */
  44096. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44097. /**
  44098. * A function executed each frame that updates the mesh (if needed)
  44099. * @param xrFrame the current xrFrame
  44100. */
  44101. protected abstract _updateModel(xrFrame: XRFrame): void;
  44102. private _getGenericFilenameAndPath;
  44103. private _getGenericParentMesh;
  44104. }
  44105. }
  44106. declare module BABYLON {
  44107. /**
  44108. * A generic trigger-only motion controller for WebXR
  44109. */
  44110. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44111. /**
  44112. * Static version of the profile id of this controller
  44113. */
  44114. static ProfileId: string;
  44115. profileId: string;
  44116. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44117. protected _getFilenameAndPath(): {
  44118. filename: string;
  44119. path: string;
  44120. };
  44121. protected _getModelLoadingConstraints(): boolean;
  44122. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44123. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44124. protected _updateModel(): void;
  44125. }
  44126. }
  44127. declare module BABYLON {
  44128. /**
  44129. * Class containing static functions to help procedurally build meshes
  44130. */
  44131. export class SphereBuilder {
  44132. /**
  44133. * Creates a sphere mesh
  44134. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44135. * * 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`)
  44136. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44137. * * 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
  44138. * * 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)
  44139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44140. * * 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
  44141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44142. * @param name defines the name of the mesh
  44143. * @param options defines the options used to create the mesh
  44144. * @param scene defines the hosting scene
  44145. * @returns the sphere mesh
  44146. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44147. */
  44148. static CreateSphere(name: string, options: {
  44149. segments?: number;
  44150. diameter?: number;
  44151. diameterX?: number;
  44152. diameterY?: number;
  44153. diameterZ?: number;
  44154. arc?: number;
  44155. slice?: number;
  44156. sideOrientation?: number;
  44157. frontUVs?: Vector4;
  44158. backUVs?: Vector4;
  44159. updatable?: boolean;
  44160. }, scene?: Nullable<Scene>): Mesh;
  44161. }
  44162. }
  44163. declare module BABYLON {
  44164. /**
  44165. * A profiled motion controller has its profile loaded from an online repository.
  44166. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44167. */
  44168. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44169. private _repositoryUrl;
  44170. private _buttonMeshMapping;
  44171. private _touchDots;
  44172. /**
  44173. * The profile ID of this controller. Will be populated when the controller initializes.
  44174. */
  44175. profileId: string;
  44176. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44177. dispose(): void;
  44178. protected _getFilenameAndPath(): {
  44179. filename: string;
  44180. path: string;
  44181. };
  44182. protected _getModelLoadingConstraints(): boolean;
  44183. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44184. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44185. protected _updateModel(_xrFrame: XRFrame): void;
  44186. }
  44187. }
  44188. declare module BABYLON {
  44189. /**
  44190. * A construction function type to create a new controller based on an xrInput object
  44191. */
  44192. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44193. /**
  44194. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44195. *
  44196. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44197. * it should be replaced with auto-loaded controllers.
  44198. *
  44199. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44200. */
  44201. export class WebXRMotionControllerManager {
  44202. private static _AvailableControllers;
  44203. private static _Fallbacks;
  44204. private static _ProfileLoadingPromises;
  44205. private static _ProfilesList;
  44206. /**
  44207. * The base URL of the online controller repository. Can be changed at any time.
  44208. */
  44209. static BaseRepositoryUrl: string;
  44210. /**
  44211. * Which repository gets priority - local or online
  44212. */
  44213. static PrioritizeOnlineRepository: boolean;
  44214. /**
  44215. * Use the online repository, or use only locally-defined controllers
  44216. */
  44217. static UseOnlineRepository: boolean;
  44218. /**
  44219. * Clear the cache used for profile loading and reload when requested again
  44220. */
  44221. static ClearProfilesCache(): void;
  44222. /**
  44223. * Register the default fallbacks.
  44224. * This function is called automatically when this file is imported.
  44225. */
  44226. static DefaultFallbacks(): void;
  44227. /**
  44228. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44229. * @param profileId the profile to which a fallback needs to be found
  44230. * @return an array with corresponding fallback profiles
  44231. */
  44232. static FindFallbackWithProfileId(profileId: string): string[];
  44233. /**
  44234. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44235. * The order of search:
  44236. *
  44237. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44238. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44239. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44240. * 4) return the generic trigger controller if none were found
  44241. *
  44242. * @param xrInput the xrInput to which a new controller is initialized
  44243. * @param scene the scene to which the model will be added
  44244. * @param forceProfile force a certain profile for this controller
  44245. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44246. */
  44247. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44248. /**
  44249. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44250. *
  44251. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44252. *
  44253. * @param type the profile type to register
  44254. * @param constructFunction the function to be called when loading this profile
  44255. */
  44256. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44257. /**
  44258. * Register a fallback to a specific profile.
  44259. * @param profileId the profileId that will receive the fallbacks
  44260. * @param fallbacks A list of fallback profiles
  44261. */
  44262. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44263. /**
  44264. * Will update the list of profiles available in the repository
  44265. * @return a promise that resolves to a map of profiles available online
  44266. */
  44267. static UpdateProfilesList(): Promise<{
  44268. [profile: string]: string;
  44269. }>;
  44270. private static _LoadProfileFromRepository;
  44271. private static _LoadProfilesFromAvailableControllers;
  44272. }
  44273. }
  44274. declare module BABYLON {
  44275. /**
  44276. * Configuration options for the WebXR controller creation
  44277. */
  44278. export interface IWebXRControllerOptions {
  44279. /**
  44280. * Should the controller mesh be animated when a user interacts with it
  44281. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44282. */
  44283. disableMotionControllerAnimation?: boolean;
  44284. /**
  44285. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44286. */
  44287. doNotLoadControllerMesh?: boolean;
  44288. /**
  44289. * Force a specific controller type for this controller.
  44290. * This can be used when creating your own profile or when testing different controllers
  44291. */
  44292. forceControllerProfile?: string;
  44293. }
  44294. /**
  44295. * Represents an XR controller
  44296. */
  44297. export class WebXRInputSource {
  44298. private _scene;
  44299. /** The underlying input source for the controller */
  44300. inputSource: XRInputSource;
  44301. private _options;
  44302. private _tmpQuaternion;
  44303. private _tmpVector;
  44304. private _uniqueId;
  44305. /**
  44306. * 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
  44307. */
  44308. grip?: AbstractMesh;
  44309. /**
  44310. * If available, this is the gamepad object related to this controller.
  44311. * Using this object it is possible to get click events and trackpad changes of the
  44312. * webxr controller that is currently being used.
  44313. */
  44314. motionController?: WebXRAbstractMotionController;
  44315. /**
  44316. * Event that fires when the controller is removed/disposed.
  44317. * The object provided as event data is this controller, after associated assets were disposed.
  44318. * uniqueId is still available.
  44319. */
  44320. onDisposeObservable: Observable<WebXRInputSource>;
  44321. /**
  44322. * Will be triggered when the mesh associated with the motion controller is done loading.
  44323. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44324. * A shortened version of controller -> motion controller -> on mesh loaded.
  44325. */
  44326. onMeshLoadedObservable: Observable<AbstractMesh>;
  44327. /**
  44328. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44329. */
  44330. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44331. /**
  44332. * Pointer which can be used to select objects or attach a visible laser to
  44333. */
  44334. pointer: AbstractMesh;
  44335. /**
  44336. * Creates the controller
  44337. * @see https://doc.babylonjs.com/how_to/webxr
  44338. * @param _scene the scene which the controller should be associated to
  44339. * @param inputSource the underlying input source for the controller
  44340. * @param _options options for this controller creation
  44341. */
  44342. constructor(_scene: Scene,
  44343. /** The underlying input source for the controller */
  44344. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44345. /**
  44346. * Get this controllers unique id
  44347. */
  44348. get uniqueId(): string;
  44349. /**
  44350. * Disposes of the object
  44351. */
  44352. dispose(): void;
  44353. /**
  44354. * Gets a world space ray coming from the pointer or grip
  44355. * @param result the resulting ray
  44356. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44357. */
  44358. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44359. /**
  44360. * Updates the controller pose based on the given XRFrame
  44361. * @param xrFrame xr frame to update the pose with
  44362. * @param referenceSpace reference space to use
  44363. */
  44364. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44365. }
  44366. }
  44367. declare module BABYLON {
  44368. /**
  44369. * The schema for initialization options of the XR Input class
  44370. */
  44371. export interface IWebXRInputOptions {
  44372. /**
  44373. * If set to true no model will be automatically loaded
  44374. */
  44375. doNotLoadControllerMeshes?: boolean;
  44376. /**
  44377. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44378. * If not found, the xr input profile data will be used.
  44379. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44380. */
  44381. forceInputProfile?: string;
  44382. /**
  44383. * Do not send a request to the controller repository to load the profile.
  44384. *
  44385. * Instead, use the controllers available in babylon itself.
  44386. */
  44387. disableOnlineControllerRepository?: boolean;
  44388. /**
  44389. * A custom URL for the controllers repository
  44390. */
  44391. customControllersRepositoryURL?: string;
  44392. /**
  44393. * Should the controller model's components not move according to the user input
  44394. */
  44395. disableControllerAnimation?: boolean;
  44396. }
  44397. /**
  44398. * XR input used to track XR inputs such as controllers/rays
  44399. */
  44400. export class WebXRInput implements IDisposable {
  44401. /**
  44402. * the xr session manager for this session
  44403. */
  44404. xrSessionManager: WebXRSessionManager;
  44405. /**
  44406. * the WebXR camera for this session. Mainly used for teleportation
  44407. */
  44408. xrCamera: WebXRCamera;
  44409. private readonly options;
  44410. /**
  44411. * XR controllers being tracked
  44412. */
  44413. controllers: Array<WebXRInputSource>;
  44414. private _frameObserver;
  44415. private _sessionEndedObserver;
  44416. private _sessionInitObserver;
  44417. /**
  44418. * Event when a controller has been connected/added
  44419. */
  44420. onControllerAddedObservable: Observable<WebXRInputSource>;
  44421. /**
  44422. * Event when a controller has been removed/disconnected
  44423. */
  44424. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44425. /**
  44426. * Initializes the WebXRInput
  44427. * @param xrSessionManager the xr session manager for this session
  44428. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44429. * @param options = initialization options for this xr input
  44430. */
  44431. constructor(
  44432. /**
  44433. * the xr session manager for this session
  44434. */
  44435. xrSessionManager: WebXRSessionManager,
  44436. /**
  44437. * the WebXR camera for this session. Mainly used for teleportation
  44438. */
  44439. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44440. private _onInputSourcesChange;
  44441. private _addAndRemoveControllers;
  44442. /**
  44443. * Disposes of the object
  44444. */
  44445. dispose(): void;
  44446. }
  44447. }
  44448. declare module BABYLON {
  44449. /**
  44450. * This is the base class for all WebXR features.
  44451. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44452. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44453. */
  44454. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44455. protected _xrSessionManager: WebXRSessionManager;
  44456. private _attached;
  44457. private _removeOnDetach;
  44458. /**
  44459. * Should auto-attach be disabled?
  44460. */
  44461. disableAutoAttach: boolean;
  44462. /**
  44463. * Construct a new (abstract) WebXR feature
  44464. * @param _xrSessionManager the xr session manager for this feature
  44465. */
  44466. constructor(_xrSessionManager: WebXRSessionManager);
  44467. /**
  44468. * Is this feature attached
  44469. */
  44470. get attached(): boolean;
  44471. /**
  44472. * attach this feature
  44473. *
  44474. * @param force should attachment be forced (even when already attached)
  44475. * @returns true if successful, false is failed or already attached
  44476. */
  44477. attach(force?: boolean): boolean;
  44478. /**
  44479. * detach this feature.
  44480. *
  44481. * @returns true if successful, false if failed or already detached
  44482. */
  44483. detach(): boolean;
  44484. /**
  44485. * Dispose this feature and all of the resources attached
  44486. */
  44487. dispose(): void;
  44488. /**
  44489. * This is used to register callbacks that will automatically be removed when detach is called.
  44490. * @param observable the observable to which the observer will be attached
  44491. * @param callback the callback to register
  44492. */
  44493. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44494. /**
  44495. * Code in this function will be executed on each xrFrame received from the browser.
  44496. * This function will not execute after the feature is detached.
  44497. * @param _xrFrame the current frame
  44498. */
  44499. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44500. }
  44501. }
  44502. declare module BABYLON {
  44503. /**
  44504. * Renders a layer on top of an existing scene
  44505. */
  44506. export class UtilityLayerRenderer implements IDisposable {
  44507. /** the original scene that will be rendered on top of */
  44508. originalScene: Scene;
  44509. private _pointerCaptures;
  44510. private _lastPointerEvents;
  44511. private static _DefaultUtilityLayer;
  44512. private static _DefaultKeepDepthUtilityLayer;
  44513. private _sharedGizmoLight;
  44514. private _renderCamera;
  44515. /**
  44516. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44517. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44518. * @returns the camera that is used when rendering the utility layer
  44519. */
  44520. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44521. /**
  44522. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44523. * @param cam the camera that should be used when rendering the utility layer
  44524. */
  44525. setRenderCamera(cam: Nullable<Camera>): void;
  44526. /**
  44527. * @hidden
  44528. * Light which used by gizmos to get light shading
  44529. */
  44530. _getSharedGizmoLight(): HemisphericLight;
  44531. /**
  44532. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44533. */
  44534. pickUtilitySceneFirst: boolean;
  44535. /**
  44536. * 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)
  44537. */
  44538. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44539. /**
  44540. * 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)
  44541. */
  44542. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44543. /**
  44544. * The scene that is rendered on top of the original scene
  44545. */
  44546. utilityLayerScene: Scene;
  44547. /**
  44548. * If the utility layer should automatically be rendered on top of existing scene
  44549. */
  44550. shouldRender: boolean;
  44551. /**
  44552. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44553. */
  44554. onlyCheckPointerDownEvents: boolean;
  44555. /**
  44556. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44557. */
  44558. processAllEvents: boolean;
  44559. /**
  44560. * Observable raised when the pointer move from the utility layer scene to the main scene
  44561. */
  44562. onPointerOutObservable: Observable<number>;
  44563. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44564. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44565. private _afterRenderObserver;
  44566. private _sceneDisposeObserver;
  44567. private _originalPointerObserver;
  44568. /**
  44569. * Instantiates a UtilityLayerRenderer
  44570. * @param originalScene the original scene that will be rendered on top of
  44571. * @param handleEvents boolean indicating if the utility layer should handle events
  44572. */
  44573. constructor(
  44574. /** the original scene that will be rendered on top of */
  44575. originalScene: Scene, handleEvents?: boolean);
  44576. private _notifyObservers;
  44577. /**
  44578. * Renders the utility layers scene on top of the original scene
  44579. */
  44580. render(): void;
  44581. /**
  44582. * Disposes of the renderer
  44583. */
  44584. dispose(): void;
  44585. private _updateCamera;
  44586. }
  44587. }
  44588. declare module BABYLON {
  44589. /**
  44590. * Options interface for the pointer selection module
  44591. */
  44592. export interface IWebXRControllerPointerSelectionOptions {
  44593. /**
  44594. * if provided, this scene will be used to render meshes.
  44595. */
  44596. customUtilityLayerScene?: Scene;
  44597. /**
  44598. * 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)
  44599. * If not disabled, the last picked point will be used to execute a pointer up event
  44600. * If disabled, pointer up event will be triggered right after the pointer down event.
  44601. * Used in screen and gaze target ray mode only
  44602. */
  44603. disablePointerUpOnTouchOut: boolean;
  44604. /**
  44605. * For gaze mode (time to select instead of press)
  44606. */
  44607. forceGazeMode: boolean;
  44608. /**
  44609. * 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
  44610. * to start a new countdown to the pointer down event.
  44611. * Defaults to 1.
  44612. */
  44613. gazeModePointerMovedFactor?: number;
  44614. /**
  44615. * Different button type to use instead of the main component
  44616. */
  44617. overrideButtonId?: string;
  44618. /**
  44619. * use this rendering group id for the meshes (optional)
  44620. */
  44621. renderingGroupId?: number;
  44622. /**
  44623. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44624. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44625. * 3000 means 3 seconds between pointing at something and selecting it
  44626. */
  44627. timeToSelect?: number;
  44628. /**
  44629. * Should meshes created here be added to a utility layer or the main scene
  44630. */
  44631. useUtilityLayer?: boolean;
  44632. /**
  44633. * the xr input to use with this pointer selection
  44634. */
  44635. xrInput: WebXRInput;
  44636. }
  44637. /**
  44638. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44639. */
  44640. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44641. private readonly _options;
  44642. private static _idCounter;
  44643. private _attachController;
  44644. private _controllers;
  44645. private _scene;
  44646. private _tmpVectorForPickCompare;
  44647. /**
  44648. * The module's name
  44649. */
  44650. static readonly Name: string;
  44651. /**
  44652. * The (Babylon) version of this module.
  44653. * This is an integer representing the implementation version.
  44654. * This number does not correspond to the WebXR specs version
  44655. */
  44656. static readonly Version: number;
  44657. /**
  44658. * Disable lighting on the laser pointer (so it will always be visible)
  44659. */
  44660. disablePointerLighting: boolean;
  44661. /**
  44662. * Disable lighting on the selection mesh (so it will always be visible)
  44663. */
  44664. disableSelectionMeshLighting: boolean;
  44665. /**
  44666. * Should the laser pointer be displayed
  44667. */
  44668. displayLaserPointer: boolean;
  44669. /**
  44670. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44671. */
  44672. displaySelectionMesh: boolean;
  44673. /**
  44674. * This color will be set to the laser pointer when selection is triggered
  44675. */
  44676. laserPointerPickedColor: Color3;
  44677. /**
  44678. * Default color of the laser pointer
  44679. */
  44680. lasterPointerDefaultColor: Color3;
  44681. /**
  44682. * default color of the selection ring
  44683. */
  44684. selectionMeshDefaultColor: Color3;
  44685. /**
  44686. * This color will be applied to the selection ring when selection is triggered
  44687. */
  44688. selectionMeshPickedColor: Color3;
  44689. /**
  44690. * Optional filter to be used for ray selection. This predicate shares behavior with
  44691. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44692. */
  44693. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44694. /**
  44695. * constructs a new background remover module
  44696. * @param _xrSessionManager the session manager for this module
  44697. * @param _options read-only options to be used in this module
  44698. */
  44699. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44700. /**
  44701. * attach this feature
  44702. * Will usually be called by the features manager
  44703. *
  44704. * @returns true if successful.
  44705. */
  44706. attach(): boolean;
  44707. /**
  44708. * detach this feature.
  44709. * Will usually be called by the features manager
  44710. *
  44711. * @returns true if successful.
  44712. */
  44713. detach(): boolean;
  44714. /**
  44715. * Will get the mesh under a specific pointer.
  44716. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44717. * @param controllerId the controllerId to check
  44718. * @returns The mesh under pointer or null if no mesh is under the pointer
  44719. */
  44720. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44721. /**
  44722. * Get the xr controller that correlates to the pointer id in the pointer event
  44723. *
  44724. * @param id the pointer id to search for
  44725. * @returns the controller that correlates to this id or null if not found
  44726. */
  44727. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44728. protected _onXRFrame(_xrFrame: XRFrame): void;
  44729. private _attachGazeMode;
  44730. private _attachScreenRayMode;
  44731. private _attachTrackedPointerRayMode;
  44732. private _convertNormalToDirectionOfRay;
  44733. private _detachController;
  44734. private _generateNewMeshPair;
  44735. private _pickingMoved;
  44736. private _updatePointerDistance;
  44737. }
  44738. }
  44739. declare module BABYLON {
  44740. /**
  44741. * Button which can be used to enter a different mode of XR
  44742. */
  44743. export class WebXREnterExitUIButton {
  44744. /** button element */
  44745. element: HTMLElement;
  44746. /** XR initialization options for the button */
  44747. sessionMode: XRSessionMode;
  44748. /** Reference space type */
  44749. referenceSpaceType: XRReferenceSpaceType;
  44750. /**
  44751. * Creates a WebXREnterExitUIButton
  44752. * @param element button element
  44753. * @param sessionMode XR initialization session mode
  44754. * @param referenceSpaceType the type of reference space to be used
  44755. */
  44756. constructor(
  44757. /** button element */
  44758. element: HTMLElement,
  44759. /** XR initialization options for the button */
  44760. sessionMode: XRSessionMode,
  44761. /** Reference space type */
  44762. referenceSpaceType: XRReferenceSpaceType);
  44763. /**
  44764. * Extendable function which can be used to update the button's visuals when the state changes
  44765. * @param activeButton the current active button in the UI
  44766. */
  44767. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44768. }
  44769. /**
  44770. * Options to create the webXR UI
  44771. */
  44772. export class WebXREnterExitUIOptions {
  44773. /**
  44774. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44775. */
  44776. customButtons?: Array<WebXREnterExitUIButton>;
  44777. /**
  44778. * A reference space type to use when creating the default button.
  44779. * Default is local-floor
  44780. */
  44781. referenceSpaceType?: XRReferenceSpaceType;
  44782. /**
  44783. * Context to enter xr with
  44784. */
  44785. renderTarget?: Nullable<WebXRRenderTarget>;
  44786. /**
  44787. * A session mode to use when creating the default button.
  44788. * Default is immersive-vr
  44789. */
  44790. sessionMode?: XRSessionMode;
  44791. }
  44792. /**
  44793. * UI to allow the user to enter/exit XR mode
  44794. */
  44795. export class WebXREnterExitUI implements IDisposable {
  44796. private scene;
  44797. /** version of the options passed to this UI */
  44798. options: WebXREnterExitUIOptions;
  44799. private _activeButton;
  44800. private _buttons;
  44801. private _overlay;
  44802. /**
  44803. * Fired every time the active button is changed.
  44804. *
  44805. * When xr is entered via a button that launches xr that button will be the callback parameter
  44806. *
  44807. * When exiting xr the callback parameter will be null)
  44808. */
  44809. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44810. /**
  44811. *
  44812. * @param scene babylon scene object to use
  44813. * @param options (read-only) version of the options passed to this UI
  44814. */
  44815. private constructor();
  44816. /**
  44817. * Creates UI to allow the user to enter/exit XR mode
  44818. * @param scene the scene to add the ui to
  44819. * @param helper the xr experience helper to enter/exit xr with
  44820. * @param options options to configure the UI
  44821. * @returns the created ui
  44822. */
  44823. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44824. /**
  44825. * Disposes of the XR UI component
  44826. */
  44827. dispose(): void;
  44828. private _updateButtons;
  44829. }
  44830. }
  44831. declare module BABYLON {
  44832. /**
  44833. * Class containing static functions to help procedurally build meshes
  44834. */
  44835. export class LinesBuilder {
  44836. /**
  44837. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44838. * * 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
  44839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44840. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44841. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44842. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44843. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44844. * * 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
  44845. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44848. * @param name defines the name of the new line system
  44849. * @param options defines the options used to create the line system
  44850. * @param scene defines the hosting scene
  44851. * @returns a new line system mesh
  44852. */
  44853. static CreateLineSystem(name: string, options: {
  44854. lines: Vector3[][];
  44855. updatable?: boolean;
  44856. instance?: Nullable<LinesMesh>;
  44857. colors?: Nullable<Color4[][]>;
  44858. useVertexAlpha?: boolean;
  44859. }, scene: Nullable<Scene>): LinesMesh;
  44860. /**
  44861. * Creates a line mesh
  44862. * 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
  44863. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44864. * * The parameter `points` is an array successive Vector3
  44865. * * 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
  44866. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44867. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44868. * * When updating an instance, remember that only point positions can change, not the number of points
  44869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44871. * @param name defines the name of the new line system
  44872. * @param options defines the options used to create the line system
  44873. * @param scene defines the hosting scene
  44874. * @returns a new line mesh
  44875. */
  44876. static CreateLines(name: string, options: {
  44877. points: Vector3[];
  44878. updatable?: boolean;
  44879. instance?: Nullable<LinesMesh>;
  44880. colors?: Color4[];
  44881. useVertexAlpha?: boolean;
  44882. }, scene?: Nullable<Scene>): LinesMesh;
  44883. /**
  44884. * Creates a dashed line mesh
  44885. * * 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
  44886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44887. * * The parameter `points` is an array successive Vector3
  44888. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44889. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44890. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44891. * * 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
  44892. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44893. * * When updating an instance, remember that only point positions can change, not the number of points
  44894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44895. * @param name defines the name of the mesh
  44896. * @param options defines the options used to create the mesh
  44897. * @param scene defines the hosting scene
  44898. * @returns the dashed line mesh
  44899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44900. */
  44901. static CreateDashedLines(name: string, options: {
  44902. points: Vector3[];
  44903. dashSize?: number;
  44904. gapSize?: number;
  44905. dashNb?: number;
  44906. updatable?: boolean;
  44907. instance?: LinesMesh;
  44908. useVertexAlpha?: boolean;
  44909. }, scene?: Nullable<Scene>): LinesMesh;
  44910. }
  44911. }
  44912. declare module BABYLON {
  44913. /**
  44914. * The options container for the teleportation module
  44915. */
  44916. export interface IWebXRTeleportationOptions {
  44917. /**
  44918. * if provided, this scene will be used to render meshes.
  44919. */
  44920. customUtilityLayerScene?: Scene;
  44921. /**
  44922. * Values to configure the default target mesh
  44923. */
  44924. defaultTargetMeshOptions?: {
  44925. /**
  44926. * Fill color of the teleportation area
  44927. */
  44928. teleportationFillColor?: string;
  44929. /**
  44930. * Border color for the teleportation area
  44931. */
  44932. teleportationBorderColor?: string;
  44933. /**
  44934. * Disable the mesh's animation sequence
  44935. */
  44936. disableAnimation?: boolean;
  44937. /**
  44938. * Disable lighting on the material or the ring and arrow
  44939. */
  44940. disableLighting?: boolean;
  44941. /**
  44942. * Override the default material of the torus and arrow
  44943. */
  44944. torusArrowMaterial?: Material;
  44945. };
  44946. /**
  44947. * A list of meshes to use as floor meshes.
  44948. * Meshes can be added and removed after initializing the feature using the
  44949. * addFloorMesh and removeFloorMesh functions
  44950. * If empty, rotation will still work
  44951. */
  44952. floorMeshes?: AbstractMesh[];
  44953. /**
  44954. * use this rendering group id for the meshes (optional)
  44955. */
  44956. renderingGroupId?: number;
  44957. /**
  44958. * Should teleportation move only to snap points
  44959. */
  44960. snapPointsOnly?: boolean;
  44961. /**
  44962. * An array of points to which the teleportation will snap to.
  44963. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44964. */
  44965. snapPositions?: Vector3[];
  44966. /**
  44967. * How close should the teleportation ray be in order to snap to position.
  44968. * Default to 0.8 units (meters)
  44969. */
  44970. snapToPositionRadius?: number;
  44971. /**
  44972. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44973. * If you want to support rotation, make sure your mesh has a direction indicator.
  44974. *
  44975. * When left untouched, the default mesh will be initialized.
  44976. */
  44977. teleportationTargetMesh?: AbstractMesh;
  44978. /**
  44979. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44980. */
  44981. timeToTeleport?: number;
  44982. /**
  44983. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44984. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44985. */
  44986. useMainComponentOnly?: boolean;
  44987. /**
  44988. * Should meshes created here be added to a utility layer or the main scene
  44989. */
  44990. useUtilityLayer?: boolean;
  44991. /**
  44992. * Babylon XR Input class for controller
  44993. */
  44994. xrInput: WebXRInput;
  44995. }
  44996. /**
  44997. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44998. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44999. * the input of the attached controllers.
  45000. */
  45001. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45002. private _options;
  45003. private _controllers;
  45004. private _currentTeleportationControllerId;
  45005. private _floorMeshes;
  45006. private _quadraticBezierCurve;
  45007. private _selectionFeature;
  45008. private _snapToPositions;
  45009. private _snappedToPoint;
  45010. private _teleportationRingMaterial?;
  45011. private _tmpRay;
  45012. private _tmpVector;
  45013. /**
  45014. * The module's name
  45015. */
  45016. static readonly Name: string;
  45017. /**
  45018. * The (Babylon) version of this module.
  45019. * This is an integer representing the implementation version.
  45020. * This number does not correspond to the webxr specs version
  45021. */
  45022. static readonly Version: number;
  45023. /**
  45024. * Is movement backwards enabled
  45025. */
  45026. backwardsMovementEnabled: boolean;
  45027. /**
  45028. * Distance to travel when moving backwards
  45029. */
  45030. backwardsTeleportationDistance: number;
  45031. /**
  45032. * The distance from the user to the inspection point in the direction of the controller
  45033. * A higher number will allow the user to move further
  45034. * defaults to 5 (meters, in xr units)
  45035. */
  45036. parabolicCheckRadius: number;
  45037. /**
  45038. * Should the module support parabolic ray on top of direct ray
  45039. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45040. * Very helpful when moving between floors / different heights
  45041. */
  45042. parabolicRayEnabled: boolean;
  45043. /**
  45044. * How much rotation should be applied when rotating right and left
  45045. */
  45046. rotationAngle: number;
  45047. /**
  45048. * Is rotation enabled when moving forward?
  45049. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45050. */
  45051. rotationEnabled: boolean;
  45052. /**
  45053. * constructs a new anchor system
  45054. * @param _xrSessionManager an instance of WebXRSessionManager
  45055. * @param _options configuration object for this feature
  45056. */
  45057. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45058. /**
  45059. * Get the snapPointsOnly flag
  45060. */
  45061. get snapPointsOnly(): boolean;
  45062. /**
  45063. * Sets the snapPointsOnly flag
  45064. * @param snapToPoints should teleportation be exclusively to snap points
  45065. */
  45066. set snapPointsOnly(snapToPoints: boolean);
  45067. /**
  45068. * Add a new mesh to the floor meshes array
  45069. * @param mesh the mesh to use as floor mesh
  45070. */
  45071. addFloorMesh(mesh: AbstractMesh): void;
  45072. /**
  45073. * Add a new snap-to point to fix teleportation to this position
  45074. * @param newSnapPoint The new Snap-To point
  45075. */
  45076. addSnapPoint(newSnapPoint: Vector3): void;
  45077. attach(): boolean;
  45078. detach(): boolean;
  45079. dispose(): void;
  45080. /**
  45081. * Remove a mesh from the floor meshes array
  45082. * @param mesh the mesh to remove
  45083. */
  45084. removeFloorMesh(mesh: AbstractMesh): void;
  45085. /**
  45086. * Remove a mesh from the floor meshes array using its name
  45087. * @param name the mesh name to remove
  45088. */
  45089. removeFloorMeshByName(name: string): void;
  45090. /**
  45091. * 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
  45092. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45093. * @returns was the point found and removed or not
  45094. */
  45095. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45096. /**
  45097. * This function sets a selection feature that will be disabled when
  45098. * the forward ray is shown and will be reattached when hidden.
  45099. * This is used to remove the selection rays when moving.
  45100. * @param selectionFeature the feature to disable when forward movement is enabled
  45101. */
  45102. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45103. protected _onXRFrame(_xrFrame: XRFrame): void;
  45104. private _attachController;
  45105. private _createDefaultTargetMesh;
  45106. private _detachController;
  45107. private _findClosestSnapPointWithRadius;
  45108. private _setTargetMeshPosition;
  45109. private _setTargetMeshVisibility;
  45110. private _showParabolicPath;
  45111. private _teleportForward;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. /**
  45116. * Options for the default xr helper
  45117. */
  45118. export class WebXRDefaultExperienceOptions {
  45119. /**
  45120. * Enable or disable default UI to enter XR
  45121. */
  45122. disableDefaultUI?: boolean;
  45123. /**
  45124. * Should teleportation not initialize. defaults to false.
  45125. */
  45126. disableTeleportation?: boolean;
  45127. /**
  45128. * Floor meshes that will be used for teleport
  45129. */
  45130. floorMeshes?: Array<AbstractMesh>;
  45131. /**
  45132. * If set to true, the first frame will not be used to reset position
  45133. * The first frame is mainly used when copying transformation from the old camera
  45134. * Mainly used in AR
  45135. */
  45136. ignoreNativeCameraTransformation?: boolean;
  45137. /**
  45138. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45139. */
  45140. inputOptions?: IWebXRInputOptions;
  45141. /**
  45142. * optional configuration for the output canvas
  45143. */
  45144. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45145. /**
  45146. * optional UI options. This can be used among other to change session mode and reference space type
  45147. */
  45148. uiOptions?: WebXREnterExitUIOptions;
  45149. /**
  45150. * When loading teleportation and pointer select, use stable versions instead of latest.
  45151. */
  45152. useStablePlugins?: boolean;
  45153. }
  45154. /**
  45155. * Default experience which provides a similar setup to the previous webVRExperience
  45156. */
  45157. export class WebXRDefaultExperience {
  45158. /**
  45159. * Base experience
  45160. */
  45161. baseExperience: WebXRExperienceHelper;
  45162. /**
  45163. * Enables ui for entering/exiting xr
  45164. */
  45165. enterExitUI: WebXREnterExitUI;
  45166. /**
  45167. * Input experience extension
  45168. */
  45169. input: WebXRInput;
  45170. /**
  45171. * Enables laser pointer and selection
  45172. */
  45173. pointerSelection: WebXRControllerPointerSelection;
  45174. /**
  45175. * Default target xr should render to
  45176. */
  45177. renderTarget: WebXRRenderTarget;
  45178. /**
  45179. * Enables teleportation
  45180. */
  45181. teleportation: WebXRMotionControllerTeleportation;
  45182. private constructor();
  45183. /**
  45184. * Creates the default xr experience
  45185. * @param scene scene
  45186. * @param options options for basic configuration
  45187. * @returns resulting WebXRDefaultExperience
  45188. */
  45189. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45190. /**
  45191. * DIsposes of the experience helper
  45192. */
  45193. dispose(): void;
  45194. }
  45195. }
  45196. declare module BABYLON {
  45197. /**
  45198. * Options to modify the vr teleportation behavior.
  45199. */
  45200. export interface VRTeleportationOptions {
  45201. /**
  45202. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45203. */
  45204. floorMeshName?: string;
  45205. /**
  45206. * A list of meshes to be used as the teleportation floor. (default: empty)
  45207. */
  45208. floorMeshes?: Mesh[];
  45209. /**
  45210. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45211. */
  45212. teleportationMode?: number;
  45213. /**
  45214. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45215. */
  45216. teleportationTime?: number;
  45217. /**
  45218. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45219. */
  45220. teleportationSpeed?: number;
  45221. /**
  45222. * The easing function used in the animation or null for Linear. (default CircleEase)
  45223. */
  45224. easingFunction?: EasingFunction;
  45225. }
  45226. /**
  45227. * Options to modify the vr experience helper's behavior.
  45228. */
  45229. export interface VRExperienceHelperOptions extends WebVROptions {
  45230. /**
  45231. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45232. */
  45233. createDeviceOrientationCamera?: boolean;
  45234. /**
  45235. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45236. */
  45237. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45238. /**
  45239. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45240. */
  45241. laserToggle?: boolean;
  45242. /**
  45243. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45244. */
  45245. floorMeshes?: Mesh[];
  45246. /**
  45247. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45248. */
  45249. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45250. /**
  45251. * Defines if WebXR should be used instead of WebVR (if available)
  45252. */
  45253. useXR?: boolean;
  45254. }
  45255. /**
  45256. * Event containing information after VR has been entered
  45257. */
  45258. export class OnAfterEnteringVRObservableEvent {
  45259. /**
  45260. * If entering vr was successful
  45261. */
  45262. success: boolean;
  45263. }
  45264. /**
  45265. * Helps to quickly add VR support to an existing scene.
  45266. * See http://doc.babylonjs.com/how_to/webvr_helper
  45267. */
  45268. export class VRExperienceHelper {
  45269. /** Options to modify the vr experience helper's behavior. */
  45270. webVROptions: VRExperienceHelperOptions;
  45271. private _scene;
  45272. private _position;
  45273. private _btnVR;
  45274. private _btnVRDisplayed;
  45275. private _webVRsupported;
  45276. private _webVRready;
  45277. private _webVRrequesting;
  45278. private _webVRpresenting;
  45279. private _hasEnteredVR;
  45280. private _fullscreenVRpresenting;
  45281. private _inputElement;
  45282. private _webVRCamera;
  45283. private _vrDeviceOrientationCamera;
  45284. private _deviceOrientationCamera;
  45285. private _existingCamera;
  45286. private _onKeyDown;
  45287. private _onVrDisplayPresentChange;
  45288. private _onVRDisplayChanged;
  45289. private _onVRRequestPresentStart;
  45290. private _onVRRequestPresentComplete;
  45291. /**
  45292. * 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)
  45293. */
  45294. enableGazeEvenWhenNoPointerLock: boolean;
  45295. /**
  45296. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45297. */
  45298. exitVROnDoubleTap: boolean;
  45299. /**
  45300. * Observable raised right before entering VR.
  45301. */
  45302. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45303. /**
  45304. * Observable raised when entering VR has completed.
  45305. */
  45306. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45307. /**
  45308. * Observable raised when exiting VR.
  45309. */
  45310. onExitingVRObservable: Observable<VRExperienceHelper>;
  45311. /**
  45312. * Observable raised when controller mesh is loaded.
  45313. */
  45314. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45315. /** Return this.onEnteringVRObservable
  45316. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45317. */
  45318. get onEnteringVR(): Observable<VRExperienceHelper>;
  45319. /** Return this.onExitingVRObservable
  45320. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45321. */
  45322. get onExitingVR(): Observable<VRExperienceHelper>;
  45323. /** Return this.onControllerMeshLoadedObservable
  45324. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45325. */
  45326. get onControllerMeshLoaded(): Observable<WebVRController>;
  45327. private _rayLength;
  45328. private _useCustomVRButton;
  45329. private _teleportationRequested;
  45330. private _teleportActive;
  45331. private _floorMeshName;
  45332. private _floorMeshesCollection;
  45333. private _teleportationMode;
  45334. private _teleportationTime;
  45335. private _teleportationSpeed;
  45336. private _teleportationEasing;
  45337. private _rotationAllowed;
  45338. private _teleportBackwardsVector;
  45339. private _teleportationTarget;
  45340. private _isDefaultTeleportationTarget;
  45341. private _postProcessMove;
  45342. private _teleportationFillColor;
  45343. private _teleportationBorderColor;
  45344. private _rotationAngle;
  45345. private _haloCenter;
  45346. private _cameraGazer;
  45347. private _padSensibilityUp;
  45348. private _padSensibilityDown;
  45349. private _leftController;
  45350. private _rightController;
  45351. private _gazeColor;
  45352. private _laserColor;
  45353. private _pickedLaserColor;
  45354. private _pickedGazeColor;
  45355. /**
  45356. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45357. */
  45358. onNewMeshSelected: Observable<AbstractMesh>;
  45359. /**
  45360. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45361. * This observable will provide the mesh and the controller used to select the mesh
  45362. */
  45363. onMeshSelectedWithController: Observable<{
  45364. mesh: AbstractMesh;
  45365. controller: WebVRController;
  45366. }>;
  45367. /**
  45368. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45369. */
  45370. onNewMeshPicked: Observable<PickingInfo>;
  45371. private _circleEase;
  45372. /**
  45373. * Observable raised before camera teleportation
  45374. */
  45375. onBeforeCameraTeleport: Observable<Vector3>;
  45376. /**
  45377. * Observable raised after camera teleportation
  45378. */
  45379. onAfterCameraTeleport: Observable<Vector3>;
  45380. /**
  45381. * Observable raised when current selected mesh gets unselected
  45382. */
  45383. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45384. private _raySelectionPredicate;
  45385. /**
  45386. * To be optionaly changed by user to define custom ray selection
  45387. */
  45388. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45389. /**
  45390. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45391. */
  45392. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45393. /**
  45394. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45395. */
  45396. teleportationEnabled: boolean;
  45397. private _defaultHeight;
  45398. private _teleportationInitialized;
  45399. private _interactionsEnabled;
  45400. private _interactionsRequested;
  45401. private _displayGaze;
  45402. private _displayLaserPointer;
  45403. /**
  45404. * The mesh used to display where the user is going to teleport.
  45405. */
  45406. get teleportationTarget(): Mesh;
  45407. /**
  45408. * Sets the mesh to be used to display where the user is going to teleport.
  45409. */
  45410. set teleportationTarget(value: Mesh);
  45411. /**
  45412. * 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
  45413. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45414. * See http://doc.babylonjs.com/resources/baking_transformations
  45415. */
  45416. get gazeTrackerMesh(): Mesh;
  45417. set gazeTrackerMesh(value: Mesh);
  45418. /**
  45419. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45420. */
  45421. updateGazeTrackerScale: boolean;
  45422. /**
  45423. * If the gaze trackers color should be updated when selecting meshes
  45424. */
  45425. updateGazeTrackerColor: boolean;
  45426. /**
  45427. * If the controller laser color should be updated when selecting meshes
  45428. */
  45429. updateControllerLaserColor: boolean;
  45430. /**
  45431. * The gaze tracking mesh corresponding to the left controller
  45432. */
  45433. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45434. /**
  45435. * The gaze tracking mesh corresponding to the right controller
  45436. */
  45437. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45438. /**
  45439. * If the ray of the gaze should be displayed.
  45440. */
  45441. get displayGaze(): boolean;
  45442. /**
  45443. * Sets if the ray of the gaze should be displayed.
  45444. */
  45445. set displayGaze(value: boolean);
  45446. /**
  45447. * If the ray of the LaserPointer should be displayed.
  45448. */
  45449. get displayLaserPointer(): boolean;
  45450. /**
  45451. * Sets if the ray of the LaserPointer should be displayed.
  45452. */
  45453. set displayLaserPointer(value: boolean);
  45454. /**
  45455. * The deviceOrientationCamera used as the camera when not in VR.
  45456. */
  45457. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45458. /**
  45459. * Based on the current WebVR support, returns the current VR camera used.
  45460. */
  45461. get currentVRCamera(): Nullable<Camera>;
  45462. /**
  45463. * The webVRCamera which is used when in VR.
  45464. */
  45465. get webVRCamera(): WebVRFreeCamera;
  45466. /**
  45467. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45468. */
  45469. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45470. /**
  45471. * The html button that is used to trigger entering into VR.
  45472. */
  45473. get vrButton(): Nullable<HTMLButtonElement>;
  45474. private get _teleportationRequestInitiated();
  45475. /**
  45476. * Defines whether or not Pointer lock should be requested when switching to
  45477. * full screen.
  45478. */
  45479. requestPointerLockOnFullScreen: boolean;
  45480. /**
  45481. * If asking to force XR, this will be populated with the default xr experience
  45482. */
  45483. xr: WebXRDefaultExperience;
  45484. /**
  45485. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45486. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45487. */
  45488. xrTestDone: boolean;
  45489. /**
  45490. * Instantiates a VRExperienceHelper.
  45491. * Helps to quickly add VR support to an existing scene.
  45492. * @param scene The scene the VRExperienceHelper belongs to.
  45493. * @param webVROptions Options to modify the vr experience helper's behavior.
  45494. */
  45495. constructor(scene: Scene,
  45496. /** Options to modify the vr experience helper's behavior. */
  45497. webVROptions?: VRExperienceHelperOptions);
  45498. private completeVRInit;
  45499. private _onDefaultMeshLoaded;
  45500. private _onResize;
  45501. private _onFullscreenChange;
  45502. /**
  45503. * Gets a value indicating if we are currently in VR mode.
  45504. */
  45505. get isInVRMode(): boolean;
  45506. private onVrDisplayPresentChange;
  45507. private onVRDisplayChanged;
  45508. private moveButtonToBottomRight;
  45509. private displayVRButton;
  45510. private updateButtonVisibility;
  45511. private _cachedAngularSensibility;
  45512. /**
  45513. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45514. * Otherwise, will use the fullscreen API.
  45515. */
  45516. enterVR(): void;
  45517. /**
  45518. * Attempt to exit VR, or fullscreen.
  45519. */
  45520. exitVR(): void;
  45521. /**
  45522. * The position of the vr experience helper.
  45523. */
  45524. get position(): Vector3;
  45525. /**
  45526. * Sets the position of the vr experience helper.
  45527. */
  45528. set position(value: Vector3);
  45529. /**
  45530. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45531. */
  45532. enableInteractions(): void;
  45533. private get _noControllerIsActive();
  45534. private beforeRender;
  45535. private _isTeleportationFloor;
  45536. /**
  45537. * Adds a floor mesh to be used for teleportation.
  45538. * @param floorMesh the mesh to be used for teleportation.
  45539. */
  45540. addFloorMesh(floorMesh: Mesh): void;
  45541. /**
  45542. * Removes a floor mesh from being used for teleportation.
  45543. * @param floorMesh the mesh to be removed.
  45544. */
  45545. removeFloorMesh(floorMesh: Mesh): void;
  45546. /**
  45547. * Enables interactions and teleportation using the VR controllers and gaze.
  45548. * @param vrTeleportationOptions options to modify teleportation behavior.
  45549. */
  45550. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45551. private _onNewGamepadConnected;
  45552. private _tryEnableInteractionOnController;
  45553. private _onNewGamepadDisconnected;
  45554. private _enableInteractionOnController;
  45555. private _checkTeleportWithRay;
  45556. private _checkRotate;
  45557. private _checkTeleportBackwards;
  45558. private _enableTeleportationOnController;
  45559. private _createTeleportationCircles;
  45560. private _displayTeleportationTarget;
  45561. private _hideTeleportationTarget;
  45562. private _rotateCamera;
  45563. private _moveTeleportationSelectorTo;
  45564. private _workingVector;
  45565. private _workingQuaternion;
  45566. private _workingMatrix;
  45567. /**
  45568. * Time Constant Teleportation Mode
  45569. */
  45570. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45571. /**
  45572. * Speed Constant Teleportation Mode
  45573. */
  45574. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45575. /**
  45576. * Teleports the users feet to the desired location
  45577. * @param location The location where the user's feet should be placed
  45578. */
  45579. teleportCamera(location: Vector3): void;
  45580. private _convertNormalToDirectionOfRay;
  45581. private _castRayAndSelectObject;
  45582. private _notifySelectedMeshUnselected;
  45583. /**
  45584. * Permanently set new colors for the laser pointer
  45585. * @param color the new laser color
  45586. * @param pickedColor the new laser color when picked mesh detected
  45587. */
  45588. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45589. /**
  45590. * Set lighting enabled / disabled on the laser pointer of both controllers
  45591. * @param enabled should the lighting be enabled on the laser pointer
  45592. */
  45593. setLaserLightingState(enabled?: boolean): void;
  45594. /**
  45595. * Permanently set new colors for the gaze pointer
  45596. * @param color the new gaze color
  45597. * @param pickedColor the new gaze color when picked mesh detected
  45598. */
  45599. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45600. /**
  45601. * Sets the color of the laser ray from the vr controllers.
  45602. * @param color new color for the ray.
  45603. */
  45604. changeLaserColor(color: Color3): void;
  45605. /**
  45606. * Sets the color of the ray from the vr headsets gaze.
  45607. * @param color new color for the ray.
  45608. */
  45609. changeGazeColor(color: Color3): void;
  45610. /**
  45611. * Exits VR and disposes of the vr experience helper
  45612. */
  45613. dispose(): void;
  45614. /**
  45615. * Gets the name of the VRExperienceHelper class
  45616. * @returns "VRExperienceHelper"
  45617. */
  45618. getClassName(): string;
  45619. }
  45620. }
  45621. declare module BABYLON {
  45622. /**
  45623. * Contains an array of blocks representing the octree
  45624. */
  45625. export interface IOctreeContainer<T> {
  45626. /**
  45627. * Blocks within the octree
  45628. */
  45629. blocks: Array<OctreeBlock<T>>;
  45630. }
  45631. /**
  45632. * Class used to store a cell in an octree
  45633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45634. */
  45635. export class OctreeBlock<T> {
  45636. /**
  45637. * Gets the content of the current block
  45638. */
  45639. entries: T[];
  45640. /**
  45641. * Gets the list of block children
  45642. */
  45643. blocks: Array<OctreeBlock<T>>;
  45644. private _depth;
  45645. private _maxDepth;
  45646. private _capacity;
  45647. private _minPoint;
  45648. private _maxPoint;
  45649. private _boundingVectors;
  45650. private _creationFunc;
  45651. /**
  45652. * Creates a new block
  45653. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45654. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45655. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45656. * @param depth defines the current depth of this block in the octree
  45657. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45658. * @param creationFunc defines a callback to call when an element is added to the block
  45659. */
  45660. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45661. /**
  45662. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45663. */
  45664. get capacity(): number;
  45665. /**
  45666. * Gets the minimum vector (in world space) of the block's bounding box
  45667. */
  45668. get minPoint(): Vector3;
  45669. /**
  45670. * Gets the maximum vector (in world space) of the block's bounding box
  45671. */
  45672. get maxPoint(): Vector3;
  45673. /**
  45674. * Add a new element to this block
  45675. * @param entry defines the element to add
  45676. */
  45677. addEntry(entry: T): void;
  45678. /**
  45679. * Remove an element from this block
  45680. * @param entry defines the element to remove
  45681. */
  45682. removeEntry(entry: T): void;
  45683. /**
  45684. * Add an array of elements to this block
  45685. * @param entries defines the array of elements to add
  45686. */
  45687. addEntries(entries: T[]): void;
  45688. /**
  45689. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45690. * @param frustumPlanes defines the frustum planes to test
  45691. * @param selection defines the array to store current content if selection is positive
  45692. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45693. */
  45694. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45695. /**
  45696. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45697. * @param sphereCenter defines the bounding sphere center
  45698. * @param sphereRadius defines the bounding sphere radius
  45699. * @param selection defines the array to store current content if selection is positive
  45700. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45701. */
  45702. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45703. /**
  45704. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45705. * @param ray defines the ray to test with
  45706. * @param selection defines the array to store current content if selection is positive
  45707. */
  45708. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45709. /**
  45710. * Subdivide the content into child blocks (this block will then be empty)
  45711. */
  45712. createInnerBlocks(): void;
  45713. /**
  45714. * @hidden
  45715. */
  45716. 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;
  45717. }
  45718. }
  45719. declare module BABYLON {
  45720. /**
  45721. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45722. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45723. */
  45724. export class Octree<T> {
  45725. /** 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.) */
  45726. maxDepth: number;
  45727. /**
  45728. * Blocks within the octree containing objects
  45729. */
  45730. blocks: Array<OctreeBlock<T>>;
  45731. /**
  45732. * Content stored in the octree
  45733. */
  45734. dynamicContent: T[];
  45735. private _maxBlockCapacity;
  45736. private _selectionContent;
  45737. private _creationFunc;
  45738. /**
  45739. * Creates a octree
  45740. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45741. * @param creationFunc function to be used to instatiate the octree
  45742. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45743. * @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.)
  45744. */
  45745. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45746. /** 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.) */
  45747. maxDepth?: number);
  45748. /**
  45749. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45750. * @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);
  45751. * @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);
  45752. * @param entries meshes to be added to the octree blocks
  45753. */
  45754. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45755. /**
  45756. * Adds a mesh to the octree
  45757. * @param entry Mesh to add to the octree
  45758. */
  45759. addMesh(entry: T): void;
  45760. /**
  45761. * Remove an element from the octree
  45762. * @param entry defines the element to remove
  45763. */
  45764. removeMesh(entry: T): void;
  45765. /**
  45766. * Selects an array of meshes within the frustum
  45767. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45768. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45769. * @returns array of meshes within the frustum
  45770. */
  45771. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45772. /**
  45773. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45774. * @param sphereCenter defines the bounding sphere center
  45775. * @param sphereRadius defines the bounding sphere radius
  45776. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45777. * @returns an array of objects that intersect the sphere
  45778. */
  45779. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45780. /**
  45781. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45782. * @param ray defines the ray to test with
  45783. * @returns array of intersected objects
  45784. */
  45785. intersectsRay(ray: Ray): SmartArray<T>;
  45786. /**
  45787. * Adds a mesh into the octree block if it intersects the block
  45788. */
  45789. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45790. /**
  45791. * Adds a submesh into the octree block if it intersects the block
  45792. */
  45793. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45794. }
  45795. }
  45796. declare module BABYLON {
  45797. interface Scene {
  45798. /**
  45799. * @hidden
  45800. * Backing Filed
  45801. */
  45802. _selectionOctree: Octree<AbstractMesh>;
  45803. /**
  45804. * Gets the octree used to boost mesh selection (picking)
  45805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45806. */
  45807. selectionOctree: Octree<AbstractMesh>;
  45808. /**
  45809. * Creates or updates the octree used to boost selection (picking)
  45810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45811. * @param maxCapacity defines the maximum capacity per leaf
  45812. * @param maxDepth defines the maximum depth of the octree
  45813. * @returns an octree of AbstractMesh
  45814. */
  45815. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45816. }
  45817. interface AbstractMesh {
  45818. /**
  45819. * @hidden
  45820. * Backing Field
  45821. */
  45822. _submeshesOctree: Octree<SubMesh>;
  45823. /**
  45824. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45825. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45826. * @param maxCapacity defines the maximum size of each block (64 by default)
  45827. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45828. * @returns the new octree
  45829. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45831. */
  45832. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45833. }
  45834. /**
  45835. * Defines the octree scene component responsible to manage any octrees
  45836. * in a given scene.
  45837. */
  45838. export class OctreeSceneComponent {
  45839. /**
  45840. * The component name help to identify the component in the list of scene components.
  45841. */
  45842. readonly name: string;
  45843. /**
  45844. * The scene the component belongs to.
  45845. */
  45846. scene: Scene;
  45847. /**
  45848. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45849. */
  45850. readonly checksIsEnabled: boolean;
  45851. /**
  45852. * Creates a new instance of the component for the given scene
  45853. * @param scene Defines the scene to register the component in
  45854. */
  45855. constructor(scene: Scene);
  45856. /**
  45857. * Registers the component in a given scene
  45858. */
  45859. register(): void;
  45860. /**
  45861. * Return the list of active meshes
  45862. * @returns the list of active meshes
  45863. */
  45864. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45865. /**
  45866. * Return the list of active sub meshes
  45867. * @param mesh The mesh to get the candidates sub meshes from
  45868. * @returns the list of active sub meshes
  45869. */
  45870. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45871. private _tempRay;
  45872. /**
  45873. * Return the list of sub meshes intersecting with a given local ray
  45874. * @param mesh defines the mesh to find the submesh for
  45875. * @param localRay defines the ray in local space
  45876. * @returns the list of intersecting sub meshes
  45877. */
  45878. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45879. /**
  45880. * Return the list of sub meshes colliding with a collider
  45881. * @param mesh defines the mesh to find the submesh for
  45882. * @param collider defines the collider to evaluate the collision against
  45883. * @returns the list of colliding sub meshes
  45884. */
  45885. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45886. /**
  45887. * Rebuilds the elements related to this component in case of
  45888. * context lost for instance.
  45889. */
  45890. rebuild(): void;
  45891. /**
  45892. * Disposes the component and the associated ressources.
  45893. */
  45894. dispose(): void;
  45895. }
  45896. }
  45897. declare module BABYLON {
  45898. /**
  45899. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45900. */
  45901. export class Gizmo implements IDisposable {
  45902. /** The utility layer the gizmo will be added to */
  45903. gizmoLayer: UtilityLayerRenderer;
  45904. /**
  45905. * The root mesh of the gizmo
  45906. */
  45907. _rootMesh: Mesh;
  45908. private _attachedMesh;
  45909. /**
  45910. * Ratio for the scale of the gizmo (Default: 1)
  45911. */
  45912. scaleRatio: number;
  45913. /**
  45914. * If a custom mesh has been set (Default: false)
  45915. */
  45916. protected _customMeshSet: boolean;
  45917. /**
  45918. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45919. * * When set, interactions will be enabled
  45920. */
  45921. get attachedMesh(): Nullable<AbstractMesh>;
  45922. set attachedMesh(value: Nullable<AbstractMesh>);
  45923. /**
  45924. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45925. * @param mesh The mesh to replace the default mesh of the gizmo
  45926. */
  45927. setCustomMesh(mesh: Mesh): void;
  45928. /**
  45929. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45930. */
  45931. updateGizmoRotationToMatchAttachedMesh: boolean;
  45932. /**
  45933. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45934. */
  45935. updateGizmoPositionToMatchAttachedMesh: boolean;
  45936. /**
  45937. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45938. */
  45939. updateScale: boolean;
  45940. protected _interactionsEnabled: boolean;
  45941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45942. private _beforeRenderObserver;
  45943. private _tempVector;
  45944. /**
  45945. * Creates a gizmo
  45946. * @param gizmoLayer The utility layer the gizmo will be added to
  45947. */
  45948. constructor(
  45949. /** The utility layer the gizmo will be added to */
  45950. gizmoLayer?: UtilityLayerRenderer);
  45951. /**
  45952. * Updates the gizmo to match the attached mesh's position/rotation
  45953. */
  45954. protected _update(): void;
  45955. /**
  45956. * Disposes of the gizmo
  45957. */
  45958. dispose(): void;
  45959. }
  45960. }
  45961. declare module BABYLON {
  45962. /**
  45963. * Single plane drag gizmo
  45964. */
  45965. export class PlaneDragGizmo extends Gizmo {
  45966. /**
  45967. * Drag behavior responsible for the gizmos dragging interactions
  45968. */
  45969. dragBehavior: PointerDragBehavior;
  45970. private _pointerObserver;
  45971. /**
  45972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45973. */
  45974. snapDistance: number;
  45975. /**
  45976. * Event that fires each time the gizmo snaps to a new location.
  45977. * * snapDistance is the the change in distance
  45978. */
  45979. onSnapObservable: Observable<{
  45980. snapDistance: number;
  45981. }>;
  45982. private _plane;
  45983. private _coloredMaterial;
  45984. private _hoverMaterial;
  45985. private _isEnabled;
  45986. private _parent;
  45987. /** @hidden */
  45988. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45989. /** @hidden */
  45990. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45991. /**
  45992. * Creates a PlaneDragGizmo
  45993. * @param gizmoLayer The utility layer the gizmo will be added to
  45994. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45995. * @param color The color of the gizmo
  45996. */
  45997. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45998. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45999. /**
  46000. * If the gizmo is enabled
  46001. */
  46002. set isEnabled(value: boolean);
  46003. get isEnabled(): boolean;
  46004. /**
  46005. * Disposes of the gizmo
  46006. */
  46007. dispose(): void;
  46008. }
  46009. }
  46010. declare module BABYLON {
  46011. /**
  46012. * Gizmo that enables dragging a mesh along 3 axis
  46013. */
  46014. export class PositionGizmo extends Gizmo {
  46015. /**
  46016. * Internal gizmo used for interactions on the x axis
  46017. */
  46018. xGizmo: AxisDragGizmo;
  46019. /**
  46020. * Internal gizmo used for interactions on the y axis
  46021. */
  46022. yGizmo: AxisDragGizmo;
  46023. /**
  46024. * Internal gizmo used for interactions on the z axis
  46025. */
  46026. zGizmo: AxisDragGizmo;
  46027. /**
  46028. * Internal gizmo used for interactions on the yz plane
  46029. */
  46030. xPlaneGizmo: PlaneDragGizmo;
  46031. /**
  46032. * Internal gizmo used for interactions on the xz plane
  46033. */
  46034. yPlaneGizmo: PlaneDragGizmo;
  46035. /**
  46036. * Internal gizmo used for interactions on the xy plane
  46037. */
  46038. zPlaneGizmo: PlaneDragGizmo;
  46039. /**
  46040. * private variables
  46041. */
  46042. private _meshAttached;
  46043. private _updateGizmoRotationToMatchAttachedMesh;
  46044. private _snapDistance;
  46045. private _scaleRatio;
  46046. /** Fires an event when any of it's sub gizmos are dragged */
  46047. onDragStartObservable: Observable<unknown>;
  46048. /** Fires an event when any of it's sub gizmos are released from dragging */
  46049. onDragEndObservable: Observable<unknown>;
  46050. /**
  46051. * If set to true, planar drag is enabled
  46052. */
  46053. private _planarGizmoEnabled;
  46054. get attachedMesh(): Nullable<AbstractMesh>;
  46055. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46056. /**
  46057. * Creates a PositionGizmo
  46058. * @param gizmoLayer The utility layer the gizmo will be added to
  46059. */
  46060. constructor(gizmoLayer?: UtilityLayerRenderer);
  46061. /**
  46062. * If the planar drag gizmo is enabled
  46063. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46064. */
  46065. set planarGizmoEnabled(value: boolean);
  46066. get planarGizmoEnabled(): boolean;
  46067. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46068. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46069. /**
  46070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46071. */
  46072. set snapDistance(value: number);
  46073. get snapDistance(): number;
  46074. /**
  46075. * Ratio for the scale of the gizmo (Default: 1)
  46076. */
  46077. set scaleRatio(value: number);
  46078. get scaleRatio(): number;
  46079. /**
  46080. * Disposes of the gizmo
  46081. */
  46082. dispose(): void;
  46083. /**
  46084. * CustomMeshes are not supported by this gizmo
  46085. * @param mesh The mesh to replace the default mesh of the gizmo
  46086. */
  46087. setCustomMesh(mesh: Mesh): void;
  46088. }
  46089. }
  46090. declare module BABYLON {
  46091. /**
  46092. * Single axis drag gizmo
  46093. */
  46094. export class AxisDragGizmo extends Gizmo {
  46095. /**
  46096. * Drag behavior responsible for the gizmos dragging interactions
  46097. */
  46098. dragBehavior: PointerDragBehavior;
  46099. private _pointerObserver;
  46100. /**
  46101. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46102. */
  46103. snapDistance: number;
  46104. /**
  46105. * Event that fires each time the gizmo snaps to a new location.
  46106. * * snapDistance is the the change in distance
  46107. */
  46108. onSnapObservable: Observable<{
  46109. snapDistance: number;
  46110. }>;
  46111. private _isEnabled;
  46112. private _parent;
  46113. private _arrow;
  46114. private _coloredMaterial;
  46115. private _hoverMaterial;
  46116. /** @hidden */
  46117. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46118. /** @hidden */
  46119. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46120. /**
  46121. * Creates an AxisDragGizmo
  46122. * @param gizmoLayer The utility layer the gizmo will be added to
  46123. * @param dragAxis The axis which the gizmo will be able to drag on
  46124. * @param color The color of the gizmo
  46125. */
  46126. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46128. /**
  46129. * If the gizmo is enabled
  46130. */
  46131. set isEnabled(value: boolean);
  46132. get isEnabled(): boolean;
  46133. /**
  46134. * Disposes of the gizmo
  46135. */
  46136. dispose(): void;
  46137. }
  46138. }
  46139. declare module BABYLON.Debug {
  46140. /**
  46141. * The Axes viewer will show 3 axes in a specific point in space
  46142. */
  46143. export class AxesViewer {
  46144. private _xAxis;
  46145. private _yAxis;
  46146. private _zAxis;
  46147. private _scaleLinesFactor;
  46148. private _instanced;
  46149. /**
  46150. * Gets the hosting scene
  46151. */
  46152. scene: Scene;
  46153. /**
  46154. * Gets or sets a number used to scale line length
  46155. */
  46156. scaleLines: number;
  46157. /** Gets the node hierarchy used to render x-axis */
  46158. get xAxis(): TransformNode;
  46159. /** Gets the node hierarchy used to render y-axis */
  46160. get yAxis(): TransformNode;
  46161. /** Gets the node hierarchy used to render z-axis */
  46162. get zAxis(): TransformNode;
  46163. /**
  46164. * Creates a new AxesViewer
  46165. * @param scene defines the hosting scene
  46166. * @param scaleLines defines a number used to scale line length (1 by default)
  46167. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46168. * @param xAxis defines the node hierarchy used to render the x-axis
  46169. * @param yAxis defines the node hierarchy used to render the y-axis
  46170. * @param zAxis defines the node hierarchy used to render the z-axis
  46171. */
  46172. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46173. /**
  46174. * Force the viewer to update
  46175. * @param position defines the position of the viewer
  46176. * @param xaxis defines the x axis of the viewer
  46177. * @param yaxis defines the y axis of the viewer
  46178. * @param zaxis defines the z axis of the viewer
  46179. */
  46180. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46181. /**
  46182. * Creates an instance of this axes viewer.
  46183. * @returns a new axes viewer with instanced meshes
  46184. */
  46185. createInstance(): AxesViewer;
  46186. /** Releases resources */
  46187. dispose(): void;
  46188. private static _SetRenderingGroupId;
  46189. }
  46190. }
  46191. declare module BABYLON.Debug {
  46192. /**
  46193. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46194. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46195. */
  46196. export class BoneAxesViewer extends AxesViewer {
  46197. /**
  46198. * Gets or sets the target mesh where to display the axes viewer
  46199. */
  46200. mesh: Nullable<Mesh>;
  46201. /**
  46202. * Gets or sets the target bone where to display the axes viewer
  46203. */
  46204. bone: Nullable<Bone>;
  46205. /** Gets current position */
  46206. pos: Vector3;
  46207. /** Gets direction of X axis */
  46208. xaxis: Vector3;
  46209. /** Gets direction of Y axis */
  46210. yaxis: Vector3;
  46211. /** Gets direction of Z axis */
  46212. zaxis: Vector3;
  46213. /**
  46214. * Creates a new BoneAxesViewer
  46215. * @param scene defines the hosting scene
  46216. * @param bone defines the target bone
  46217. * @param mesh defines the target mesh
  46218. * @param scaleLines defines a scaling factor for line length (1 by default)
  46219. */
  46220. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46221. /**
  46222. * Force the viewer to update
  46223. */
  46224. update(): void;
  46225. /** Releases resources */
  46226. dispose(): void;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Interface used to define scene explorer extensibility option
  46232. */
  46233. export interface IExplorerExtensibilityOption {
  46234. /**
  46235. * Define the option label
  46236. */
  46237. label: string;
  46238. /**
  46239. * Defines the action to execute on click
  46240. */
  46241. action: (entity: any) => void;
  46242. }
  46243. /**
  46244. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46245. */
  46246. export interface IExplorerExtensibilityGroup {
  46247. /**
  46248. * Defines a predicate to test if a given type mut be extended
  46249. */
  46250. predicate: (entity: any) => boolean;
  46251. /**
  46252. * Gets the list of options added to a type
  46253. */
  46254. entries: IExplorerExtensibilityOption[];
  46255. }
  46256. /**
  46257. * Interface used to define the options to use to create the Inspector
  46258. */
  46259. export interface IInspectorOptions {
  46260. /**
  46261. * Display in overlay mode (default: false)
  46262. */
  46263. overlay?: boolean;
  46264. /**
  46265. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46266. */
  46267. globalRoot?: HTMLElement;
  46268. /**
  46269. * Display the Scene explorer
  46270. */
  46271. showExplorer?: boolean;
  46272. /**
  46273. * Display the property inspector
  46274. */
  46275. showInspector?: boolean;
  46276. /**
  46277. * Display in embed mode (both panes on the right)
  46278. */
  46279. embedMode?: boolean;
  46280. /**
  46281. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46282. */
  46283. handleResize?: boolean;
  46284. /**
  46285. * Allow the panes to popup (default: true)
  46286. */
  46287. enablePopup?: boolean;
  46288. /**
  46289. * Allow the panes to be closed by users (default: true)
  46290. */
  46291. enableClose?: boolean;
  46292. /**
  46293. * Optional list of extensibility entries
  46294. */
  46295. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46296. /**
  46297. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46298. */
  46299. inspectorURL?: string;
  46300. /**
  46301. * Optional initial tab (default to DebugLayerTab.Properties)
  46302. */
  46303. initialTab?: DebugLayerTab;
  46304. }
  46305. interface Scene {
  46306. /**
  46307. * @hidden
  46308. * Backing field
  46309. */
  46310. _debugLayer: DebugLayer;
  46311. /**
  46312. * Gets the debug layer (aka Inspector) associated with the scene
  46313. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46314. */
  46315. debugLayer: DebugLayer;
  46316. }
  46317. /**
  46318. * Enum of inspector action tab
  46319. */
  46320. export enum DebugLayerTab {
  46321. /**
  46322. * Properties tag (default)
  46323. */
  46324. Properties = 0,
  46325. /**
  46326. * Debug tab
  46327. */
  46328. Debug = 1,
  46329. /**
  46330. * Statistics tab
  46331. */
  46332. Statistics = 2,
  46333. /**
  46334. * Tools tab
  46335. */
  46336. Tools = 3,
  46337. /**
  46338. * Settings tab
  46339. */
  46340. Settings = 4
  46341. }
  46342. /**
  46343. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46344. * what is happening in your scene
  46345. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46346. */
  46347. export class DebugLayer {
  46348. /**
  46349. * Define the url to get the inspector script from.
  46350. * By default it uses the babylonjs CDN.
  46351. * @ignoreNaming
  46352. */
  46353. static InspectorURL: string;
  46354. private _scene;
  46355. private BJSINSPECTOR;
  46356. private _onPropertyChangedObservable?;
  46357. /**
  46358. * Observable triggered when a property is changed through the inspector.
  46359. */
  46360. get onPropertyChangedObservable(): any;
  46361. /**
  46362. * Instantiates a new debug layer.
  46363. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46364. * what is happening in your scene
  46365. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46366. * @param scene Defines the scene to inspect
  46367. */
  46368. constructor(scene: Scene);
  46369. /** Creates the inspector window. */
  46370. private _createInspector;
  46371. /**
  46372. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46373. * @param entity defines the entity to select
  46374. * @param lineContainerTitle defines the specific block to highlight
  46375. */
  46376. select(entity: any, lineContainerTitle?: string): void;
  46377. /** Get the inspector from bundle or global */
  46378. private _getGlobalInspector;
  46379. /**
  46380. * Get if the inspector is visible or not.
  46381. * @returns true if visible otherwise, false
  46382. */
  46383. isVisible(): boolean;
  46384. /**
  46385. * Hide the inspector and close its window.
  46386. */
  46387. hide(): void;
  46388. /**
  46389. * Launch the debugLayer.
  46390. * @param config Define the configuration of the inspector
  46391. * @return a promise fulfilled when the debug layer is visible
  46392. */
  46393. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46394. }
  46395. }
  46396. declare module BABYLON {
  46397. /**
  46398. * Class containing static functions to help procedurally build meshes
  46399. */
  46400. export class BoxBuilder {
  46401. /**
  46402. * Creates a box mesh
  46403. * * The parameter `size` sets the size (float) of each box side (default 1)
  46404. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46405. * * 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)
  46406. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46408. * * 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
  46409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46410. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46411. * @param name defines the name of the mesh
  46412. * @param options defines the options used to create the mesh
  46413. * @param scene defines the hosting scene
  46414. * @returns the box mesh
  46415. */
  46416. static CreateBox(name: string, options: {
  46417. size?: number;
  46418. width?: number;
  46419. height?: number;
  46420. depth?: number;
  46421. faceUV?: Vector4[];
  46422. faceColors?: Color4[];
  46423. sideOrientation?: number;
  46424. frontUVs?: Vector4;
  46425. backUVs?: Vector4;
  46426. wrap?: boolean;
  46427. topBaseAt?: number;
  46428. bottomBaseAt?: number;
  46429. updatable?: boolean;
  46430. }, scene?: Nullable<Scene>): Mesh;
  46431. }
  46432. }
  46433. declare module BABYLON.Debug {
  46434. /**
  46435. * Used to show the physics impostor around the specific mesh
  46436. */
  46437. export class PhysicsViewer {
  46438. /** @hidden */
  46439. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46440. /** @hidden */
  46441. protected _meshes: Array<Nullable<AbstractMesh>>;
  46442. /** @hidden */
  46443. protected _scene: Nullable<Scene>;
  46444. /** @hidden */
  46445. protected _numMeshes: number;
  46446. /** @hidden */
  46447. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46448. private _renderFunction;
  46449. private _utilityLayer;
  46450. private _debugBoxMesh;
  46451. private _debugSphereMesh;
  46452. private _debugCylinderMesh;
  46453. private _debugMaterial;
  46454. private _debugMeshMeshes;
  46455. /**
  46456. * Creates a new PhysicsViewer
  46457. * @param scene defines the hosting scene
  46458. */
  46459. constructor(scene: Scene);
  46460. /** @hidden */
  46461. protected _updateDebugMeshes(): void;
  46462. /**
  46463. * Renders a specified physic impostor
  46464. * @param impostor defines the impostor to render
  46465. * @param targetMesh defines the mesh represented by the impostor
  46466. * @returns the new debug mesh used to render the impostor
  46467. */
  46468. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46469. /**
  46470. * Hides a specified physic impostor
  46471. * @param impostor defines the impostor to hide
  46472. */
  46473. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46474. private _getDebugMaterial;
  46475. private _getDebugBoxMesh;
  46476. private _getDebugSphereMesh;
  46477. private _getDebugCylinderMesh;
  46478. private _getDebugMeshMesh;
  46479. private _getDebugMesh;
  46480. /** Releases all resources */
  46481. dispose(): void;
  46482. }
  46483. }
  46484. declare module BABYLON {
  46485. /**
  46486. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46487. * in order to better appreciate the issue one might have.
  46488. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46489. */
  46490. export class RayHelper {
  46491. /**
  46492. * Defines the ray we are currently tryin to visualize.
  46493. */
  46494. ray: Nullable<Ray>;
  46495. private _renderPoints;
  46496. private _renderLine;
  46497. private _renderFunction;
  46498. private _scene;
  46499. private _updateToMeshFunction;
  46500. private _attachedToMesh;
  46501. private _meshSpaceDirection;
  46502. private _meshSpaceOrigin;
  46503. /**
  46504. * Helper function to create a colored helper in a scene in one line.
  46505. * @param ray Defines the ray we are currently tryin to visualize
  46506. * @param scene Defines the scene the ray is used in
  46507. * @param color Defines the color we want to see the ray in
  46508. * @returns The newly created ray helper.
  46509. */
  46510. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46511. /**
  46512. * Instantiate a new ray helper.
  46513. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46514. * in order to better appreciate the issue one might have.
  46515. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46516. * @param ray Defines the ray we are currently tryin to visualize
  46517. */
  46518. constructor(ray: Ray);
  46519. /**
  46520. * Shows the ray we are willing to debug.
  46521. * @param scene Defines the scene the ray needs to be rendered in
  46522. * @param color Defines the color the ray needs to be rendered in
  46523. */
  46524. show(scene: Scene, color?: Color3): void;
  46525. /**
  46526. * Hides the ray we are debugging.
  46527. */
  46528. hide(): void;
  46529. private _render;
  46530. /**
  46531. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46532. * @param mesh Defines the mesh we want the helper attached to
  46533. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46534. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46535. * @param length Defines the length of the ray
  46536. */
  46537. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46538. /**
  46539. * Detach the ray helper from the mesh it has previously been attached to.
  46540. */
  46541. detachFromMesh(): void;
  46542. private _updateToMesh;
  46543. /**
  46544. * Dispose the helper and release its associated resources.
  46545. */
  46546. dispose(): void;
  46547. }
  46548. }
  46549. declare module BABYLON.Debug {
  46550. /**
  46551. * Class used to render a debug view of a given skeleton
  46552. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46553. */
  46554. export class SkeletonViewer {
  46555. /** defines the skeleton to render */
  46556. skeleton: Skeleton;
  46557. /** defines the mesh attached to the skeleton */
  46558. mesh: AbstractMesh;
  46559. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46560. autoUpdateBonesMatrices: boolean;
  46561. /** defines the rendering group id to use with the viewer */
  46562. renderingGroupId: number;
  46563. /** Gets or sets the color used to render the skeleton */
  46564. color: Color3;
  46565. private _scene;
  46566. private _debugLines;
  46567. private _debugMesh;
  46568. private _isEnabled;
  46569. private _renderFunction;
  46570. private _utilityLayer;
  46571. /**
  46572. * Returns the mesh used to render the bones
  46573. */
  46574. get debugMesh(): Nullable<LinesMesh>;
  46575. /**
  46576. * Creates a new SkeletonViewer
  46577. * @param skeleton defines the skeleton to render
  46578. * @param mesh defines the mesh attached to the skeleton
  46579. * @param scene defines the hosting scene
  46580. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46581. * @param renderingGroupId defines the rendering group id to use with the viewer
  46582. */
  46583. constructor(
  46584. /** defines the skeleton to render */
  46585. skeleton: Skeleton,
  46586. /** defines the mesh attached to the skeleton */
  46587. mesh: AbstractMesh, scene: Scene,
  46588. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46589. autoUpdateBonesMatrices?: boolean,
  46590. /** defines the rendering group id to use with the viewer */
  46591. renderingGroupId?: number);
  46592. /** Gets or sets a boolean indicating if the viewer is enabled */
  46593. set isEnabled(value: boolean);
  46594. get isEnabled(): boolean;
  46595. private _getBonePosition;
  46596. private _getLinesForBonesWithLength;
  46597. private _getLinesForBonesNoLength;
  46598. /** Update the viewer to sync with current skeleton state */
  46599. update(): void;
  46600. /** Release associated resources */
  46601. dispose(): void;
  46602. }
  46603. }
  46604. declare module BABYLON {
  46605. /**
  46606. * Options to create the null engine
  46607. */
  46608. export class NullEngineOptions {
  46609. /**
  46610. * Render width (Default: 512)
  46611. */
  46612. renderWidth: number;
  46613. /**
  46614. * Render height (Default: 256)
  46615. */
  46616. renderHeight: number;
  46617. /**
  46618. * Texture size (Default: 512)
  46619. */
  46620. textureSize: number;
  46621. /**
  46622. * If delta time between frames should be constant
  46623. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46624. */
  46625. deterministicLockstep: boolean;
  46626. /**
  46627. * Maximum about of steps between frames (Default: 4)
  46628. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46629. */
  46630. lockstepMaxSteps: number;
  46631. }
  46632. /**
  46633. * The null engine class provides support for headless version of babylon.js.
  46634. * This can be used in server side scenario or for testing purposes
  46635. */
  46636. export class NullEngine extends Engine {
  46637. private _options;
  46638. /**
  46639. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46640. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46641. * @returns true if engine is in deterministic lock step mode
  46642. */
  46643. isDeterministicLockStep(): boolean;
  46644. /**
  46645. * Gets the max steps when engine is running in deterministic lock step
  46646. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46647. * @returns the max steps
  46648. */
  46649. getLockstepMaxSteps(): number;
  46650. /**
  46651. * Gets the current hardware scaling level.
  46652. * By default the hardware scaling level is computed from the window device ratio.
  46653. * 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.
  46654. * @returns a number indicating the current hardware scaling level
  46655. */
  46656. getHardwareScalingLevel(): number;
  46657. constructor(options?: NullEngineOptions);
  46658. /**
  46659. * Creates a vertex buffer
  46660. * @param vertices the data for the vertex buffer
  46661. * @returns the new WebGL static buffer
  46662. */
  46663. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46664. /**
  46665. * Creates a new index buffer
  46666. * @param indices defines the content of the index buffer
  46667. * @param updatable defines if the index buffer must be updatable
  46668. * @returns a new webGL buffer
  46669. */
  46670. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46671. /**
  46672. * Clear the current render buffer or the current render target (if any is set up)
  46673. * @param color defines the color to use
  46674. * @param backBuffer defines if the back buffer must be cleared
  46675. * @param depth defines if the depth buffer must be cleared
  46676. * @param stencil defines if the stencil buffer must be cleared
  46677. */
  46678. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46679. /**
  46680. * Gets the current render width
  46681. * @param useScreen defines if screen size must be used (or the current render target if any)
  46682. * @returns a number defining the current render width
  46683. */
  46684. getRenderWidth(useScreen?: boolean): number;
  46685. /**
  46686. * Gets the current render height
  46687. * @param useScreen defines if screen size must be used (or the current render target if any)
  46688. * @returns a number defining the current render height
  46689. */
  46690. getRenderHeight(useScreen?: boolean): number;
  46691. /**
  46692. * Set the WebGL's viewport
  46693. * @param viewport defines the viewport element to be used
  46694. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46695. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46696. */
  46697. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46698. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46699. /**
  46700. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46701. * @param pipelineContext defines the pipeline context to use
  46702. * @param uniformsNames defines the list of uniform names
  46703. * @returns an array of webGL uniform locations
  46704. */
  46705. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46706. /**
  46707. * Gets the lsit of active attributes for a given webGL program
  46708. * @param pipelineContext defines the pipeline context to use
  46709. * @param attributesNames defines the list of attribute names to get
  46710. * @returns an array of indices indicating the offset of each attribute
  46711. */
  46712. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46713. /**
  46714. * Binds an effect to the webGL context
  46715. * @param effect defines the effect to bind
  46716. */
  46717. bindSamplers(effect: Effect): void;
  46718. /**
  46719. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46720. * @param effect defines the effect to activate
  46721. */
  46722. enableEffect(effect: Effect): void;
  46723. /**
  46724. * Set various states to the webGL context
  46725. * @param culling defines backface culling state
  46726. * @param zOffset defines the value to apply to zOffset (0 by default)
  46727. * @param force defines if states must be applied even if cache is up to date
  46728. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46729. */
  46730. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46731. /**
  46732. * Set the value of an uniform to an array of int32
  46733. * @param uniform defines the webGL uniform location where to store the value
  46734. * @param array defines the array of int32 to store
  46735. */
  46736. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46737. /**
  46738. * Set the value of an uniform to an array of int32 (stored as vec2)
  46739. * @param uniform defines the webGL uniform location where to store the value
  46740. * @param array defines the array of int32 to store
  46741. */
  46742. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46743. /**
  46744. * Set the value of an uniform to an array of int32 (stored as vec3)
  46745. * @param uniform defines the webGL uniform location where to store the value
  46746. * @param array defines the array of int32 to store
  46747. */
  46748. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46749. /**
  46750. * Set the value of an uniform to an array of int32 (stored as vec4)
  46751. * @param uniform defines the webGL uniform location where to store the value
  46752. * @param array defines the array of int32 to store
  46753. */
  46754. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46755. /**
  46756. * Set the value of an uniform to an array of float32
  46757. * @param uniform defines the webGL uniform location where to store the value
  46758. * @param array defines the array of float32 to store
  46759. */
  46760. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46761. /**
  46762. * Set the value of an uniform to an array of float32 (stored as vec2)
  46763. * @param uniform defines the webGL uniform location where to store the value
  46764. * @param array defines the array of float32 to store
  46765. */
  46766. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46767. /**
  46768. * Set the value of an uniform to an array of float32 (stored as vec3)
  46769. * @param uniform defines the webGL uniform location where to store the value
  46770. * @param array defines the array of float32 to store
  46771. */
  46772. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46773. /**
  46774. * Set the value of an uniform to an array of float32 (stored as vec4)
  46775. * @param uniform defines the webGL uniform location where to store the value
  46776. * @param array defines the array of float32 to store
  46777. */
  46778. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46779. /**
  46780. * Set the value of an uniform to an array of number
  46781. * @param uniform defines the webGL uniform location where to store the value
  46782. * @param array defines the array of number to store
  46783. */
  46784. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46785. /**
  46786. * Set the value of an uniform to an array of number (stored as vec2)
  46787. * @param uniform defines the webGL uniform location where to store the value
  46788. * @param array defines the array of number to store
  46789. */
  46790. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46791. /**
  46792. * Set the value of an uniform to an array of number (stored as vec3)
  46793. * @param uniform defines the webGL uniform location where to store the value
  46794. * @param array defines the array of number to store
  46795. */
  46796. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46797. /**
  46798. * Set the value of an uniform to an array of number (stored as vec4)
  46799. * @param uniform defines the webGL uniform location where to store the value
  46800. * @param array defines the array of number to store
  46801. */
  46802. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46803. /**
  46804. * Set the value of an uniform to an array of float32 (stored as matrices)
  46805. * @param uniform defines the webGL uniform location where to store the value
  46806. * @param matrices defines the array of float32 to store
  46807. */
  46808. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46809. /**
  46810. * Set the value of an uniform to a matrix (3x3)
  46811. * @param uniform defines the webGL uniform location where to store the value
  46812. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46813. */
  46814. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46815. /**
  46816. * Set the value of an uniform to a matrix (2x2)
  46817. * @param uniform defines the webGL uniform location where to store the value
  46818. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46819. */
  46820. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46821. /**
  46822. * Set the value of an uniform to a number (float)
  46823. * @param uniform defines the webGL uniform location where to store the value
  46824. * @param value defines the float number to store
  46825. */
  46826. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46827. /**
  46828. * Set the value of an uniform to a vec2
  46829. * @param uniform defines the webGL uniform location where to store the value
  46830. * @param x defines the 1st component of the value
  46831. * @param y defines the 2nd component of the value
  46832. */
  46833. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46834. /**
  46835. * Set the value of an uniform to a vec3
  46836. * @param uniform defines the webGL uniform location where to store the value
  46837. * @param x defines the 1st component of the value
  46838. * @param y defines the 2nd component of the value
  46839. * @param z defines the 3rd component of the value
  46840. */
  46841. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46842. /**
  46843. * Set the value of an uniform to a boolean
  46844. * @param uniform defines the webGL uniform location where to store the value
  46845. * @param bool defines the boolean to store
  46846. */
  46847. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46848. /**
  46849. * Set the value of an uniform to a vec4
  46850. * @param uniform defines the webGL uniform location where to store the value
  46851. * @param x defines the 1st component of the value
  46852. * @param y defines the 2nd component of the value
  46853. * @param z defines the 3rd component of the value
  46854. * @param w defines the 4th component of the value
  46855. */
  46856. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46857. /**
  46858. * Sets the current alpha mode
  46859. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46860. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46861. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46862. */
  46863. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46864. /**
  46865. * Bind webGl buffers directly to the webGL context
  46866. * @param vertexBuffers defines the vertex buffer to bind
  46867. * @param indexBuffer defines the index buffer to bind
  46868. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46869. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46870. * @param effect defines the effect associated with the vertex buffer
  46871. */
  46872. bindBuffers(vertexBuffers: {
  46873. [key: string]: VertexBuffer;
  46874. }, indexBuffer: DataBuffer, effect: Effect): void;
  46875. /**
  46876. * Force the entire cache to be cleared
  46877. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46878. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46879. */
  46880. wipeCaches(bruteForce?: boolean): void;
  46881. /**
  46882. * Send a draw order
  46883. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46884. * @param indexStart defines the starting index
  46885. * @param indexCount defines the number of index to draw
  46886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46887. */
  46888. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46889. /**
  46890. * Draw a list of indexed primitives
  46891. * @param fillMode defines the primitive to use
  46892. * @param indexStart defines the starting index
  46893. * @param indexCount defines the number of index to draw
  46894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46895. */
  46896. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46897. /**
  46898. * Draw a list of unindexed primitives
  46899. * @param fillMode defines the primitive to use
  46900. * @param verticesStart defines the index of first vertex to draw
  46901. * @param verticesCount defines the count of vertices to draw
  46902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46903. */
  46904. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46905. /** @hidden */
  46906. _createTexture(): WebGLTexture;
  46907. /** @hidden */
  46908. _releaseTexture(texture: InternalTexture): void;
  46909. /**
  46910. * Usually called from Texture.ts.
  46911. * Passed information to create a WebGLTexture
  46912. * @param urlArg defines a value which contains one of the following:
  46913. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46914. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46915. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46916. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46917. * @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)
  46918. * @param scene needed for loading to the correct scene
  46919. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46920. * @param onLoad optional callback to be called upon successful completion
  46921. * @param onError optional callback to be called upon failure
  46922. * @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
  46923. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46924. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46925. * @param forcedExtension defines the extension to use to pick the right loader
  46926. * @param mimeType defines an optional mime type
  46927. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46928. */
  46929. 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;
  46930. /**
  46931. * Creates a new render target texture
  46932. * @param size defines the size of the texture
  46933. * @param options defines the options used to create the texture
  46934. * @returns a new render target texture stored in an InternalTexture
  46935. */
  46936. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46937. /**
  46938. * Update the sampling mode of a given texture
  46939. * @param samplingMode defines the required sampling mode
  46940. * @param texture defines the texture to update
  46941. */
  46942. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46943. /**
  46944. * Binds the frame buffer to the specified texture.
  46945. * @param texture The texture to render to or null for the default canvas
  46946. * @param faceIndex The face of the texture to render to in case of cube texture
  46947. * @param requiredWidth The width of the target to render to
  46948. * @param requiredHeight The height of the target to render to
  46949. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46950. * @param lodLevel defines le lod level to bind to the frame buffer
  46951. */
  46952. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46953. /**
  46954. * Unbind the current render target texture from the webGL context
  46955. * @param texture defines the render target texture to unbind
  46956. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46957. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46958. */
  46959. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46960. /**
  46961. * Creates a dynamic vertex buffer
  46962. * @param vertices the data for the dynamic vertex buffer
  46963. * @returns the new WebGL dynamic buffer
  46964. */
  46965. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46966. /**
  46967. * Update the content of a dynamic texture
  46968. * @param texture defines the texture to update
  46969. * @param canvas defines the canvas containing the source
  46970. * @param invertY defines if data must be stored with Y axis inverted
  46971. * @param premulAlpha defines if alpha is stored as premultiplied
  46972. * @param format defines the format of the data
  46973. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46974. */
  46975. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46976. /**
  46977. * Gets a boolean indicating if all created effects are ready
  46978. * @returns true if all effects are ready
  46979. */
  46980. areAllEffectsReady(): boolean;
  46981. /**
  46982. * @hidden
  46983. * Get the current error code of the webGL context
  46984. * @returns the error code
  46985. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46986. */
  46987. getError(): number;
  46988. /** @hidden */
  46989. _getUnpackAlignement(): number;
  46990. /** @hidden */
  46991. _unpackFlipY(value: boolean): void;
  46992. /**
  46993. * Update a dynamic index buffer
  46994. * @param indexBuffer defines the target index buffer
  46995. * @param indices defines the data to update
  46996. * @param offset defines the offset in the target index buffer where update should start
  46997. */
  46998. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46999. /**
  47000. * Updates a dynamic vertex buffer.
  47001. * @param vertexBuffer the vertex buffer to update
  47002. * @param vertices the data used to update the vertex buffer
  47003. * @param byteOffset the byte offset of the data (optional)
  47004. * @param byteLength the byte length of the data (optional)
  47005. */
  47006. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47007. /** @hidden */
  47008. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47009. /** @hidden */
  47010. _bindTexture(channel: number, texture: InternalTexture): void;
  47011. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47012. /**
  47013. * 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
  47014. */
  47015. releaseEffects(): void;
  47016. displayLoadingUI(): void;
  47017. hideLoadingUI(): void;
  47018. /** @hidden */
  47019. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47020. /** @hidden */
  47021. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47022. /** @hidden */
  47023. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47024. /** @hidden */
  47025. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47026. }
  47027. }
  47028. declare module BABYLON {
  47029. /**
  47030. * @hidden
  47031. **/
  47032. export class _TimeToken {
  47033. _startTimeQuery: Nullable<WebGLQuery>;
  47034. _endTimeQuery: Nullable<WebGLQuery>;
  47035. _timeElapsedQuery: Nullable<WebGLQuery>;
  47036. _timeElapsedQueryEnded: boolean;
  47037. }
  47038. }
  47039. declare module BABYLON {
  47040. /** @hidden */
  47041. export class _OcclusionDataStorage {
  47042. /** @hidden */
  47043. occlusionInternalRetryCounter: number;
  47044. /** @hidden */
  47045. isOcclusionQueryInProgress: boolean;
  47046. /** @hidden */
  47047. isOccluded: boolean;
  47048. /** @hidden */
  47049. occlusionRetryCount: number;
  47050. /** @hidden */
  47051. occlusionType: number;
  47052. /** @hidden */
  47053. occlusionQueryAlgorithmType: number;
  47054. }
  47055. interface Engine {
  47056. /**
  47057. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47058. * @return the new query
  47059. */
  47060. createQuery(): WebGLQuery;
  47061. /**
  47062. * Delete and release a webGL query
  47063. * @param query defines the query to delete
  47064. * @return the current engine
  47065. */
  47066. deleteQuery(query: WebGLQuery): Engine;
  47067. /**
  47068. * Check if a given query has resolved and got its value
  47069. * @param query defines the query to check
  47070. * @returns true if the query got its value
  47071. */
  47072. isQueryResultAvailable(query: WebGLQuery): boolean;
  47073. /**
  47074. * Gets the value of a given query
  47075. * @param query defines the query to check
  47076. * @returns the value of the query
  47077. */
  47078. getQueryResult(query: WebGLQuery): number;
  47079. /**
  47080. * Initiates an occlusion query
  47081. * @param algorithmType defines the algorithm to use
  47082. * @param query defines the query to use
  47083. * @returns the current engine
  47084. * @see http://doc.babylonjs.com/features/occlusionquery
  47085. */
  47086. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47087. /**
  47088. * Ends an occlusion query
  47089. * @see http://doc.babylonjs.com/features/occlusionquery
  47090. * @param algorithmType defines the algorithm to use
  47091. * @returns the current engine
  47092. */
  47093. endOcclusionQuery(algorithmType: number): Engine;
  47094. /**
  47095. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47096. * Please note that only one query can be issued at a time
  47097. * @returns a time token used to track the time span
  47098. */
  47099. startTimeQuery(): Nullable<_TimeToken>;
  47100. /**
  47101. * Ends a time query
  47102. * @param token defines the token used to measure the time span
  47103. * @returns the time spent (in ns)
  47104. */
  47105. endTimeQuery(token: _TimeToken): int;
  47106. /** @hidden */
  47107. _currentNonTimestampToken: Nullable<_TimeToken>;
  47108. /** @hidden */
  47109. _createTimeQuery(): WebGLQuery;
  47110. /** @hidden */
  47111. _deleteTimeQuery(query: WebGLQuery): void;
  47112. /** @hidden */
  47113. _getGlAlgorithmType(algorithmType: number): number;
  47114. /** @hidden */
  47115. _getTimeQueryResult(query: WebGLQuery): any;
  47116. /** @hidden */
  47117. _getTimeQueryAvailability(query: WebGLQuery): any;
  47118. }
  47119. interface AbstractMesh {
  47120. /**
  47121. * Backing filed
  47122. * @hidden
  47123. */
  47124. __occlusionDataStorage: _OcclusionDataStorage;
  47125. /**
  47126. * Access property
  47127. * @hidden
  47128. */
  47129. _occlusionDataStorage: _OcclusionDataStorage;
  47130. /**
  47131. * 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.
  47132. * The default value is -1 which means don't break the query and wait till the result
  47133. * @see http://doc.babylonjs.com/features/occlusionquery
  47134. */
  47135. occlusionRetryCount: number;
  47136. /**
  47137. * 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:
  47138. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47139. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47140. * * 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.
  47141. * @see http://doc.babylonjs.com/features/occlusionquery
  47142. */
  47143. occlusionType: number;
  47144. /**
  47145. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47146. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47147. * * 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.
  47148. * @see http://doc.babylonjs.com/features/occlusionquery
  47149. */
  47150. occlusionQueryAlgorithmType: number;
  47151. /**
  47152. * 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
  47153. * @see http://doc.babylonjs.com/features/occlusionquery
  47154. */
  47155. isOccluded: boolean;
  47156. /**
  47157. * Flag to check the progress status of the query
  47158. * @see http://doc.babylonjs.com/features/occlusionquery
  47159. */
  47160. isOcclusionQueryInProgress: boolean;
  47161. }
  47162. }
  47163. declare module BABYLON {
  47164. /** @hidden */
  47165. export var _forceTransformFeedbackToBundle: boolean;
  47166. interface Engine {
  47167. /**
  47168. * Creates a webGL transform feedback object
  47169. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47170. * @returns the webGL transform feedback object
  47171. */
  47172. createTransformFeedback(): WebGLTransformFeedback;
  47173. /**
  47174. * Delete a webGL transform feedback object
  47175. * @param value defines the webGL transform feedback object to delete
  47176. */
  47177. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47178. /**
  47179. * Bind a webGL transform feedback object to the webgl context
  47180. * @param value defines the webGL transform feedback object to bind
  47181. */
  47182. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47183. /**
  47184. * Begins a transform feedback operation
  47185. * @param usePoints defines if points or triangles must be used
  47186. */
  47187. beginTransformFeedback(usePoints: boolean): void;
  47188. /**
  47189. * Ends a transform feedback operation
  47190. */
  47191. endTransformFeedback(): void;
  47192. /**
  47193. * Specify the varyings to use with transform feedback
  47194. * @param program defines the associated webGL program
  47195. * @param value defines the list of strings representing the varying names
  47196. */
  47197. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47198. /**
  47199. * Bind a webGL buffer for a transform feedback operation
  47200. * @param value defines the webGL buffer to bind
  47201. */
  47202. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47203. }
  47204. }
  47205. declare module BABYLON {
  47206. /**
  47207. * Creation options of the multi render target texture.
  47208. */
  47209. export interface IMultiRenderTargetOptions {
  47210. /**
  47211. * Define if the texture needs to create mip maps after render.
  47212. */
  47213. generateMipMaps?: boolean;
  47214. /**
  47215. * Define the types of all the draw buffers we want to create
  47216. */
  47217. types?: number[];
  47218. /**
  47219. * Define the sampling modes of all the draw buffers we want to create
  47220. */
  47221. samplingModes?: number[];
  47222. /**
  47223. * Define if a depth buffer is required
  47224. */
  47225. generateDepthBuffer?: boolean;
  47226. /**
  47227. * Define if a stencil buffer is required
  47228. */
  47229. generateStencilBuffer?: boolean;
  47230. /**
  47231. * Define if a depth texture is required instead of a depth buffer
  47232. */
  47233. generateDepthTexture?: boolean;
  47234. /**
  47235. * Define the number of desired draw buffers
  47236. */
  47237. textureCount?: number;
  47238. /**
  47239. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47240. */
  47241. doNotChangeAspectRatio?: boolean;
  47242. /**
  47243. * Define the default type of the buffers we are creating
  47244. */
  47245. defaultType?: number;
  47246. }
  47247. /**
  47248. * A multi render target, like a render target provides the ability to render to a texture.
  47249. * Unlike the render target, it can render to several draw buffers in one draw.
  47250. * This is specially interesting in deferred rendering or for any effects requiring more than
  47251. * just one color from a single pass.
  47252. */
  47253. export class MultiRenderTarget extends RenderTargetTexture {
  47254. private _internalTextures;
  47255. private _textures;
  47256. private _multiRenderTargetOptions;
  47257. /**
  47258. * Get if draw buffers are currently supported by the used hardware and browser.
  47259. */
  47260. get isSupported(): boolean;
  47261. /**
  47262. * Get the list of textures generated by the multi render target.
  47263. */
  47264. get textures(): Texture[];
  47265. /**
  47266. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47267. */
  47268. get depthTexture(): Texture;
  47269. /**
  47270. * Set the wrapping mode on U of all the textures we are rendering to.
  47271. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47272. */
  47273. set wrapU(wrap: number);
  47274. /**
  47275. * Set the wrapping mode on V of all the textures we are rendering to.
  47276. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47277. */
  47278. set wrapV(wrap: number);
  47279. /**
  47280. * Instantiate a new multi render target texture.
  47281. * A multi render target, like a render target provides the ability to render to a texture.
  47282. * Unlike the render target, it can render to several draw buffers in one draw.
  47283. * This is specially interesting in deferred rendering or for any effects requiring more than
  47284. * just one color from a single pass.
  47285. * @param name Define the name of the texture
  47286. * @param size Define the size of the buffers to render to
  47287. * @param count Define the number of target we are rendering into
  47288. * @param scene Define the scene the texture belongs to
  47289. * @param options Define the options used to create the multi render target
  47290. */
  47291. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47292. /** @hidden */
  47293. _rebuild(): void;
  47294. private _createInternalTextures;
  47295. private _createTextures;
  47296. /**
  47297. * Define the number of samples used if MSAA is enabled.
  47298. */
  47299. get samples(): number;
  47300. set samples(value: number);
  47301. /**
  47302. * Resize all the textures in the multi render target.
  47303. * Be carrefull as it will recreate all the data in the new texture.
  47304. * @param size Define the new size
  47305. */
  47306. resize(size: any): void;
  47307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47308. /**
  47309. * Dispose the render targets and their associated resources
  47310. */
  47311. dispose(): void;
  47312. /**
  47313. * Release all the underlying texture used as draw buffers.
  47314. */
  47315. releaseInternalTextures(): void;
  47316. }
  47317. }
  47318. declare module BABYLON {
  47319. interface ThinEngine {
  47320. /**
  47321. * Unbind a list of render target textures from the webGL context
  47322. * This is used only when drawBuffer extension or webGL2 are active
  47323. * @param textures defines the render target textures to unbind
  47324. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47325. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47326. */
  47327. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47328. /**
  47329. * Create a multi render target texture
  47330. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47331. * @param size defines the size of the texture
  47332. * @param options defines the creation options
  47333. * @returns the cube texture as an InternalTexture
  47334. */
  47335. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47336. /**
  47337. * Update the sample count for a given multiple render target texture
  47338. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47339. * @param textures defines the textures to update
  47340. * @param samples defines the sample count to set
  47341. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47342. */
  47343. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47344. }
  47345. }
  47346. declare module BABYLON {
  47347. /**
  47348. * Class used to define an additional view for the engine
  47349. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47350. */
  47351. export class EngineView {
  47352. /** Defines the canvas where to render the view */
  47353. target: HTMLCanvasElement;
  47354. /** Defines an optional camera used to render the view (will use active camera else) */
  47355. camera?: Camera;
  47356. }
  47357. interface Engine {
  47358. /**
  47359. * Gets or sets the HTML element to use for attaching events
  47360. */
  47361. inputElement: Nullable<HTMLElement>;
  47362. /**
  47363. * Gets the current engine view
  47364. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47365. */
  47366. activeView: Nullable<EngineView>;
  47367. /** Gets or sets the list of views */
  47368. views: EngineView[];
  47369. /**
  47370. * Register a new child canvas
  47371. * @param canvas defines the canvas to register
  47372. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47373. * @returns the associated view
  47374. */
  47375. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47376. /**
  47377. * Remove a registered child canvas
  47378. * @param canvas defines the canvas to remove
  47379. * @returns the current engine
  47380. */
  47381. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47382. }
  47383. }
  47384. declare module BABYLON {
  47385. interface Engine {
  47386. /** @hidden */
  47387. _excludedCompressedTextures: string[];
  47388. /** @hidden */
  47389. _textureFormatInUse: string;
  47390. /**
  47391. * Gets the list of texture formats supported
  47392. */
  47393. readonly texturesSupported: Array<string>;
  47394. /**
  47395. * Gets the texture format in use
  47396. */
  47397. readonly textureFormatInUse: Nullable<string>;
  47398. /**
  47399. * Set the compressed texture extensions or file names to skip.
  47400. *
  47401. * @param skippedFiles defines the list of those texture files you want to skip
  47402. * Example: [".dds", ".env", "myfile.png"]
  47403. */
  47404. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47405. /**
  47406. * Set the compressed texture format to use, based on the formats you have, and the formats
  47407. * supported by the hardware / browser.
  47408. *
  47409. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47410. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47411. * to API arguments needed to compressed textures. This puts the burden on the container
  47412. * generator to house the arcane code for determining these for current & future formats.
  47413. *
  47414. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47415. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47416. *
  47417. * Note: The result of this call is not taken into account when a texture is base64.
  47418. *
  47419. * @param formatsAvailable defines the list of those format families you have created
  47420. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47421. *
  47422. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47423. * @returns The extension selected.
  47424. */
  47425. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47426. }
  47427. }
  47428. declare module BABYLON {
  47429. /**
  47430. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47431. */
  47432. export interface CubeMapInfo {
  47433. /**
  47434. * The pixel array for the front face.
  47435. * This is stored in format, left to right, up to down format.
  47436. */
  47437. front: Nullable<ArrayBufferView>;
  47438. /**
  47439. * The pixel array for the back face.
  47440. * This is stored in format, left to right, up to down format.
  47441. */
  47442. back: Nullable<ArrayBufferView>;
  47443. /**
  47444. * The pixel array for the left face.
  47445. * This is stored in format, left to right, up to down format.
  47446. */
  47447. left: Nullable<ArrayBufferView>;
  47448. /**
  47449. * The pixel array for the right face.
  47450. * This is stored in format, left to right, up to down format.
  47451. */
  47452. right: Nullable<ArrayBufferView>;
  47453. /**
  47454. * The pixel array for the up face.
  47455. * This is stored in format, left to right, up to down format.
  47456. */
  47457. up: Nullable<ArrayBufferView>;
  47458. /**
  47459. * The pixel array for the down face.
  47460. * This is stored in format, left to right, up to down format.
  47461. */
  47462. down: Nullable<ArrayBufferView>;
  47463. /**
  47464. * The size of the cubemap stored.
  47465. *
  47466. * Each faces will be size * size pixels.
  47467. */
  47468. size: number;
  47469. /**
  47470. * The format of the texture.
  47471. *
  47472. * RGBA, RGB.
  47473. */
  47474. format: number;
  47475. /**
  47476. * The type of the texture data.
  47477. *
  47478. * UNSIGNED_INT, FLOAT.
  47479. */
  47480. type: number;
  47481. /**
  47482. * Specifies whether the texture is in gamma space.
  47483. */
  47484. gammaSpace: boolean;
  47485. }
  47486. /**
  47487. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47488. */
  47489. export class PanoramaToCubeMapTools {
  47490. private static FACE_FRONT;
  47491. private static FACE_BACK;
  47492. private static FACE_RIGHT;
  47493. private static FACE_LEFT;
  47494. private static FACE_DOWN;
  47495. private static FACE_UP;
  47496. /**
  47497. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47498. *
  47499. * @param float32Array The source data.
  47500. * @param inputWidth The width of the input panorama.
  47501. * @param inputHeight The height of the input panorama.
  47502. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47503. * @return The cubemap data
  47504. */
  47505. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47506. private static CreateCubemapTexture;
  47507. private static CalcProjectionSpherical;
  47508. }
  47509. }
  47510. declare module BABYLON {
  47511. /**
  47512. * Helper class dealing with the extraction of spherical polynomial dataArray
  47513. * from a cube map.
  47514. */
  47515. export class CubeMapToSphericalPolynomialTools {
  47516. private static FileFaces;
  47517. /**
  47518. * Converts a texture to the according Spherical Polynomial data.
  47519. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47520. *
  47521. * @param texture The texture to extract the information from.
  47522. * @return The Spherical Polynomial data.
  47523. */
  47524. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47525. /**
  47526. * Converts a cubemap to the according Spherical Polynomial data.
  47527. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47528. *
  47529. * @param cubeInfo The Cube map to extract the information from.
  47530. * @return The Spherical Polynomial data.
  47531. */
  47532. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. interface BaseTexture {
  47537. /**
  47538. * Get the polynomial representation of the texture data.
  47539. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47540. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47541. */
  47542. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47543. }
  47544. }
  47545. declare module BABYLON {
  47546. /** @hidden */
  47547. export var rgbdEncodePixelShader: {
  47548. name: string;
  47549. shader: string;
  47550. };
  47551. }
  47552. declare module BABYLON {
  47553. /** @hidden */
  47554. export var rgbdDecodePixelShader: {
  47555. name: string;
  47556. shader: string;
  47557. };
  47558. }
  47559. declare module BABYLON {
  47560. /**
  47561. * Raw texture data and descriptor sufficient for WebGL texture upload
  47562. */
  47563. export interface EnvironmentTextureInfo {
  47564. /**
  47565. * Version of the environment map
  47566. */
  47567. version: number;
  47568. /**
  47569. * Width of image
  47570. */
  47571. width: number;
  47572. /**
  47573. * Irradiance information stored in the file.
  47574. */
  47575. irradiance: any;
  47576. /**
  47577. * Specular information stored in the file.
  47578. */
  47579. specular: any;
  47580. }
  47581. /**
  47582. * Defines One Image in the file. It requires only the position in the file
  47583. * as well as the length.
  47584. */
  47585. interface BufferImageData {
  47586. /**
  47587. * Length of the image data.
  47588. */
  47589. length: number;
  47590. /**
  47591. * Position of the data from the null terminator delimiting the end of the JSON.
  47592. */
  47593. position: number;
  47594. }
  47595. /**
  47596. * Defines the specular data enclosed in the file.
  47597. * This corresponds to the version 1 of the data.
  47598. */
  47599. export interface EnvironmentTextureSpecularInfoV1 {
  47600. /**
  47601. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47602. */
  47603. specularDataPosition?: number;
  47604. /**
  47605. * This contains all the images data needed to reconstruct the cubemap.
  47606. */
  47607. mipmaps: Array<BufferImageData>;
  47608. /**
  47609. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47610. */
  47611. lodGenerationScale: number;
  47612. }
  47613. /**
  47614. * Sets of helpers addressing the serialization and deserialization of environment texture
  47615. * stored in a BabylonJS env file.
  47616. * Those files are usually stored as .env files.
  47617. */
  47618. export class EnvironmentTextureTools {
  47619. /**
  47620. * Magic number identifying the env file.
  47621. */
  47622. private static _MagicBytes;
  47623. /**
  47624. * Gets the environment info from an env file.
  47625. * @param data The array buffer containing the .env bytes.
  47626. * @returns the environment file info (the json header) if successfully parsed.
  47627. */
  47628. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47629. /**
  47630. * Creates an environment texture from a loaded cube texture.
  47631. * @param texture defines the cube texture to convert in env file
  47632. * @return a promise containing the environment data if succesfull.
  47633. */
  47634. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47635. /**
  47636. * Creates a JSON representation of the spherical data.
  47637. * @param texture defines the texture containing the polynomials
  47638. * @return the JSON representation of the spherical info
  47639. */
  47640. private static _CreateEnvTextureIrradiance;
  47641. /**
  47642. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47643. * @param data the image data
  47644. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47645. * @return the views described by info providing access to the underlying buffer
  47646. */
  47647. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47648. /**
  47649. * Uploads the texture info contained in the env file to the GPU.
  47650. * @param texture defines the internal texture to upload to
  47651. * @param data defines the data to load
  47652. * @param info defines the texture info retrieved through the GetEnvInfo method
  47653. * @returns a promise
  47654. */
  47655. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47656. private static _OnImageReadyAsync;
  47657. /**
  47658. * Uploads the levels of image data to the GPU.
  47659. * @param texture defines the internal texture to upload to
  47660. * @param imageData defines the array buffer views of image data [mipmap][face]
  47661. * @returns a promise
  47662. */
  47663. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47664. /**
  47665. * Uploads spherical polynomials information to the texture.
  47666. * @param texture defines the texture we are trying to upload the information to
  47667. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47668. */
  47669. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47670. /** @hidden */
  47671. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47672. }
  47673. }
  47674. declare module BABYLON {
  47675. /**
  47676. * Contains position and normal vectors for a vertex
  47677. */
  47678. export class PositionNormalVertex {
  47679. /** the position of the vertex (defaut: 0,0,0) */
  47680. position: Vector3;
  47681. /** the normal of the vertex (defaut: 0,1,0) */
  47682. normal: Vector3;
  47683. /**
  47684. * Creates a PositionNormalVertex
  47685. * @param position the position of the vertex (defaut: 0,0,0)
  47686. * @param normal the normal of the vertex (defaut: 0,1,0)
  47687. */
  47688. constructor(
  47689. /** the position of the vertex (defaut: 0,0,0) */
  47690. position?: Vector3,
  47691. /** the normal of the vertex (defaut: 0,1,0) */
  47692. normal?: Vector3);
  47693. /**
  47694. * Clones the PositionNormalVertex
  47695. * @returns the cloned PositionNormalVertex
  47696. */
  47697. clone(): PositionNormalVertex;
  47698. }
  47699. /**
  47700. * Contains position, normal and uv vectors for a vertex
  47701. */
  47702. export class PositionNormalTextureVertex {
  47703. /** the position of the vertex (defaut: 0,0,0) */
  47704. position: Vector3;
  47705. /** the normal of the vertex (defaut: 0,1,0) */
  47706. normal: Vector3;
  47707. /** the uv of the vertex (default: 0,0) */
  47708. uv: Vector2;
  47709. /**
  47710. * Creates a PositionNormalTextureVertex
  47711. * @param position the position of the vertex (defaut: 0,0,0)
  47712. * @param normal the normal of the vertex (defaut: 0,1,0)
  47713. * @param uv the uv of the vertex (default: 0,0)
  47714. */
  47715. constructor(
  47716. /** the position of the vertex (defaut: 0,0,0) */
  47717. position?: Vector3,
  47718. /** the normal of the vertex (defaut: 0,1,0) */
  47719. normal?: Vector3,
  47720. /** the uv of the vertex (default: 0,0) */
  47721. uv?: Vector2);
  47722. /**
  47723. * Clones the PositionNormalTextureVertex
  47724. * @returns the cloned PositionNormalTextureVertex
  47725. */
  47726. clone(): PositionNormalTextureVertex;
  47727. }
  47728. }
  47729. declare module BABYLON {
  47730. /** @hidden */
  47731. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47732. private _genericAttributeLocation;
  47733. private _varyingLocationCount;
  47734. private _varyingLocationMap;
  47735. private _replacements;
  47736. private _textureCount;
  47737. private _uniforms;
  47738. lineProcessor(line: string): string;
  47739. attributeProcessor(attribute: string): string;
  47740. varyingProcessor(varying: string, isFragment: boolean): string;
  47741. uniformProcessor(uniform: string): string;
  47742. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47743. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47744. }
  47745. }
  47746. declare module BABYLON {
  47747. /**
  47748. * Container for accessors for natively-stored mesh data buffers.
  47749. */
  47750. class NativeDataBuffer extends DataBuffer {
  47751. /**
  47752. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47753. */
  47754. nativeIndexBuffer?: any;
  47755. /**
  47756. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47757. */
  47758. nativeVertexBuffer?: any;
  47759. }
  47760. /** @hidden */
  47761. class NativeTexture extends InternalTexture {
  47762. getInternalTexture(): InternalTexture;
  47763. getViewCount(): number;
  47764. }
  47765. /** @hidden */
  47766. export class NativeEngine extends Engine {
  47767. private readonly _native;
  47768. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47769. private readonly INVALID_HANDLE;
  47770. getHardwareScalingLevel(): number;
  47771. constructor();
  47772. /**
  47773. * Can be used to override the current requestAnimationFrame requester.
  47774. * @hidden
  47775. */
  47776. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47777. /**
  47778. * Override default engine behavior.
  47779. * @param color
  47780. * @param backBuffer
  47781. * @param depth
  47782. * @param stencil
  47783. */
  47784. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47785. /**
  47786. * Gets host document
  47787. * @returns the host document object
  47788. */
  47789. getHostDocument(): Nullable<Document>;
  47790. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47791. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47792. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47793. recordVertexArrayObject(vertexBuffers: {
  47794. [key: string]: VertexBuffer;
  47795. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47796. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47797. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47798. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47799. /**
  47800. * Draw a list of indexed primitives
  47801. * @param fillMode defines the primitive to use
  47802. * @param indexStart defines the starting index
  47803. * @param indexCount defines the number of index to draw
  47804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47805. */
  47806. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47807. /**
  47808. * Draw a list of unindexed primitives
  47809. * @param fillMode defines the primitive to use
  47810. * @param verticesStart defines the index of first vertex to draw
  47811. * @param verticesCount defines the count of vertices to draw
  47812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47813. */
  47814. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47815. createPipelineContext(): IPipelineContext;
  47816. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47817. /** @hidden */
  47818. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47819. /** @hidden */
  47820. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47821. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47822. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47823. protected _setProgram(program: WebGLProgram): void;
  47824. _releaseEffect(effect: Effect): void;
  47825. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47826. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47827. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47828. bindSamplers(effect: Effect): void;
  47829. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47830. getRenderWidth(useScreen?: boolean): number;
  47831. getRenderHeight(useScreen?: boolean): number;
  47832. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47833. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47834. /**
  47835. * Set the z offset to apply to current rendering
  47836. * @param value defines the offset to apply
  47837. */
  47838. setZOffset(value: number): void;
  47839. /**
  47840. * Gets the current value of the zOffset
  47841. * @returns the current zOffset state
  47842. */
  47843. getZOffset(): number;
  47844. /**
  47845. * Enable or disable depth buffering
  47846. * @param enable defines the state to set
  47847. */
  47848. setDepthBuffer(enable: boolean): void;
  47849. /**
  47850. * Gets a boolean indicating if depth writing is enabled
  47851. * @returns the current depth writing state
  47852. */
  47853. getDepthWrite(): boolean;
  47854. /**
  47855. * Enable or disable depth writing
  47856. * @param enable defines the state to set
  47857. */
  47858. setDepthWrite(enable: boolean): void;
  47859. /**
  47860. * Enable or disable color writing
  47861. * @param enable defines the state to set
  47862. */
  47863. setColorWrite(enable: boolean): void;
  47864. /**
  47865. * Gets a boolean indicating if color writing is enabled
  47866. * @returns the current color writing state
  47867. */
  47868. getColorWrite(): boolean;
  47869. /**
  47870. * Sets alpha constants used by some alpha blending modes
  47871. * @param r defines the red component
  47872. * @param g defines the green component
  47873. * @param b defines the blue component
  47874. * @param a defines the alpha component
  47875. */
  47876. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47877. /**
  47878. * Sets the current alpha mode
  47879. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47880. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47882. */
  47883. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47884. /**
  47885. * Gets the current alpha mode
  47886. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47887. * @returns the current alpha mode
  47888. */
  47889. getAlphaMode(): number;
  47890. setInt(uniform: WebGLUniformLocation, int: number): void;
  47891. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47892. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47893. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47894. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47895. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47896. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47897. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47898. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47899. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47900. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47901. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47902. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47903. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47904. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47905. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47906. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47907. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47908. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47909. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47910. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47911. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47912. wipeCaches(bruteForce?: boolean): void;
  47913. _createTexture(): WebGLTexture;
  47914. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47915. /**
  47916. * Usually called from Texture.ts.
  47917. * Passed information to create a WebGLTexture
  47918. * @param urlArg defines a value which contains one of the following:
  47919. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47920. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47921. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47922. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47923. * @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)
  47924. * @param scene needed for loading to the correct scene
  47925. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47926. * @param onLoad optional callback to be called upon successful completion
  47927. * @param onError optional callback to be called upon failure
  47928. * @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
  47929. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47930. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47931. * @param forcedExtension defines the extension to use to pick the right loader
  47932. * @param mimeType defines an optional mime type
  47933. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47934. */
  47935. 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;
  47936. /**
  47937. * Creates a cube texture
  47938. * @param rootUrl defines the url where the files to load is located
  47939. * @param scene defines the current scene
  47940. * @param files defines the list of files to load (1 per face)
  47941. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47942. * @param onLoad defines an optional callback raised when the texture is loaded
  47943. * @param onError defines an optional callback raised if there is an issue to load the texture
  47944. * @param format defines the format of the data
  47945. * @param forcedExtension defines the extension to use to pick the right loader
  47946. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47949. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47950. * @returns the cube texture as an InternalTexture
  47951. */
  47952. 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;
  47953. private _getSamplingFilter;
  47954. private static _GetNativeTextureFormat;
  47955. createRenderTargetTexture(size: number | {
  47956. width: number;
  47957. height: number;
  47958. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47959. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47960. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47961. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47962. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47963. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47964. /**
  47965. * Updates a dynamic vertex buffer.
  47966. * @param vertexBuffer the vertex buffer to update
  47967. * @param data the data used to update the vertex buffer
  47968. * @param byteOffset the byte offset of the data (optional)
  47969. * @param byteLength the byte length of the data (optional)
  47970. */
  47971. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47972. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47973. private _updateAnisotropicLevel;
  47974. private _getAddressMode;
  47975. /** @hidden */
  47976. _bindTexture(channel: number, texture: InternalTexture): void;
  47977. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47978. releaseEffects(): void;
  47979. /** @hidden */
  47980. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47981. /** @hidden */
  47982. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47983. /** @hidden */
  47984. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47985. /** @hidden */
  47986. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47987. }
  47988. }
  47989. declare module BABYLON {
  47990. /**
  47991. * Gather the list of clipboard event types as constants.
  47992. */
  47993. export class ClipboardEventTypes {
  47994. /**
  47995. * The clipboard event is fired when a copy command is active (pressed).
  47996. */
  47997. static readonly COPY: number;
  47998. /**
  47999. * The clipboard event is fired when a cut command is active (pressed).
  48000. */
  48001. static readonly CUT: number;
  48002. /**
  48003. * The clipboard event is fired when a paste command is active (pressed).
  48004. */
  48005. static readonly PASTE: number;
  48006. }
  48007. /**
  48008. * This class is used to store clipboard related info for the onClipboardObservable event.
  48009. */
  48010. export class ClipboardInfo {
  48011. /**
  48012. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48013. */
  48014. type: number;
  48015. /**
  48016. * Defines the related dom event
  48017. */
  48018. event: ClipboardEvent;
  48019. /**
  48020. *Creates an instance of ClipboardInfo.
  48021. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48022. * @param event Defines the related dom event
  48023. */
  48024. constructor(
  48025. /**
  48026. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48027. */
  48028. type: number,
  48029. /**
  48030. * Defines the related dom event
  48031. */
  48032. event: ClipboardEvent);
  48033. /**
  48034. * Get the clipboard event's type from the keycode.
  48035. * @param keyCode Defines the keyCode for the current keyboard event.
  48036. * @return {number}
  48037. */
  48038. static GetTypeFromCharacter(keyCode: number): number;
  48039. }
  48040. }
  48041. declare module BABYLON {
  48042. /**
  48043. * Google Daydream controller
  48044. */
  48045. export class DaydreamController extends WebVRController {
  48046. /**
  48047. * Base Url for the controller model.
  48048. */
  48049. static MODEL_BASE_URL: string;
  48050. /**
  48051. * File name for the controller model.
  48052. */
  48053. static MODEL_FILENAME: string;
  48054. /**
  48055. * Gamepad Id prefix used to identify Daydream Controller.
  48056. */
  48057. static readonly GAMEPAD_ID_PREFIX: string;
  48058. /**
  48059. * Creates a new DaydreamController from a gamepad
  48060. * @param vrGamepad the gamepad that the controller should be created from
  48061. */
  48062. constructor(vrGamepad: any);
  48063. /**
  48064. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48065. * @param scene scene in which to add meshes
  48066. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48067. */
  48068. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48069. /**
  48070. * Called once for each button that changed state since the last frame
  48071. * @param buttonIdx Which button index changed
  48072. * @param state New state of the button
  48073. * @param changes Which properties on the state changed since last frame
  48074. */
  48075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48076. }
  48077. }
  48078. declare module BABYLON {
  48079. /**
  48080. * Gear VR Controller
  48081. */
  48082. export class GearVRController extends WebVRController {
  48083. /**
  48084. * Base Url for the controller model.
  48085. */
  48086. static MODEL_BASE_URL: string;
  48087. /**
  48088. * File name for the controller model.
  48089. */
  48090. static MODEL_FILENAME: string;
  48091. /**
  48092. * Gamepad Id prefix used to identify this controller.
  48093. */
  48094. static readonly GAMEPAD_ID_PREFIX: string;
  48095. private readonly _buttonIndexToObservableNameMap;
  48096. /**
  48097. * Creates a new GearVRController from a gamepad
  48098. * @param vrGamepad the gamepad that the controller should be created from
  48099. */
  48100. constructor(vrGamepad: any);
  48101. /**
  48102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48103. * @param scene scene in which to add meshes
  48104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48105. */
  48106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48107. /**
  48108. * Called once for each button that changed state since the last frame
  48109. * @param buttonIdx Which button index changed
  48110. * @param state New state of the button
  48111. * @param changes Which properties on the state changed since last frame
  48112. */
  48113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48114. }
  48115. }
  48116. declare module BABYLON {
  48117. /**
  48118. * Generic Controller
  48119. */
  48120. export class GenericController extends WebVRController {
  48121. /**
  48122. * Base Url for the controller model.
  48123. */
  48124. static readonly MODEL_BASE_URL: string;
  48125. /**
  48126. * File name for the controller model.
  48127. */
  48128. static readonly MODEL_FILENAME: string;
  48129. /**
  48130. * Creates a new GenericController from a gamepad
  48131. * @param vrGamepad the gamepad that the controller should be created from
  48132. */
  48133. constructor(vrGamepad: any);
  48134. /**
  48135. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48136. * @param scene scene in which to add meshes
  48137. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48138. */
  48139. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48140. /**
  48141. * Called once for each button that changed state since the last frame
  48142. * @param buttonIdx Which button index changed
  48143. * @param state New state of the button
  48144. * @param changes Which properties on the state changed since last frame
  48145. */
  48146. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48147. }
  48148. }
  48149. declare module BABYLON {
  48150. /**
  48151. * Oculus Touch Controller
  48152. */
  48153. export class OculusTouchController extends WebVRController {
  48154. /**
  48155. * Base Url for the controller model.
  48156. */
  48157. static MODEL_BASE_URL: string;
  48158. /**
  48159. * File name for the left controller model.
  48160. */
  48161. static MODEL_LEFT_FILENAME: string;
  48162. /**
  48163. * File name for the right controller model.
  48164. */
  48165. static MODEL_RIGHT_FILENAME: string;
  48166. /**
  48167. * Base Url for the Quest controller model.
  48168. */
  48169. static QUEST_MODEL_BASE_URL: string;
  48170. /**
  48171. * @hidden
  48172. * If the controllers are running on a device that needs the updated Quest controller models
  48173. */
  48174. static _IsQuest: boolean;
  48175. /**
  48176. * Fired when the secondary trigger on this controller is modified
  48177. */
  48178. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48179. /**
  48180. * Fired when the thumb rest on this controller is modified
  48181. */
  48182. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48183. /**
  48184. * Creates a new OculusTouchController from a gamepad
  48185. * @param vrGamepad the gamepad that the controller should be created from
  48186. */
  48187. constructor(vrGamepad: any);
  48188. /**
  48189. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48190. * @param scene scene in which to add meshes
  48191. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48192. */
  48193. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48194. /**
  48195. * Fired when the A button on this controller is modified
  48196. */
  48197. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48198. /**
  48199. * Fired when the B button on this controller is modified
  48200. */
  48201. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48202. /**
  48203. * Fired when the X button on this controller is modified
  48204. */
  48205. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48206. /**
  48207. * Fired when the Y button on this controller is modified
  48208. */
  48209. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48210. /**
  48211. * Called once for each button that changed state since the last frame
  48212. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48213. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48214. * 2) secondary trigger (same)
  48215. * 3) A (right) X (left), touch, pressed = value
  48216. * 4) B / Y
  48217. * 5) thumb rest
  48218. * @param buttonIdx Which button index changed
  48219. * @param state New state of the button
  48220. * @param changes Which properties on the state changed since last frame
  48221. */
  48222. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48223. }
  48224. }
  48225. declare module BABYLON {
  48226. /**
  48227. * Vive Controller
  48228. */
  48229. export class ViveController extends WebVRController {
  48230. /**
  48231. * Base Url for the controller model.
  48232. */
  48233. static MODEL_BASE_URL: string;
  48234. /**
  48235. * File name for the controller model.
  48236. */
  48237. static MODEL_FILENAME: string;
  48238. /**
  48239. * Creates a new ViveController from a gamepad
  48240. * @param vrGamepad the gamepad that the controller should be created from
  48241. */
  48242. constructor(vrGamepad: any);
  48243. /**
  48244. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48245. * @param scene scene in which to add meshes
  48246. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48247. */
  48248. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48249. /**
  48250. * Fired when the left button on this controller is modified
  48251. */
  48252. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48253. /**
  48254. * Fired when the right button on this controller is modified
  48255. */
  48256. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48257. /**
  48258. * Fired when the menu button on this controller is modified
  48259. */
  48260. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48261. /**
  48262. * Called once for each button that changed state since the last frame
  48263. * Vive mapping:
  48264. * 0: touchpad
  48265. * 1: trigger
  48266. * 2: left AND right buttons
  48267. * 3: menu button
  48268. * @param buttonIdx Which button index changed
  48269. * @param state New state of the button
  48270. * @param changes Which properties on the state changed since last frame
  48271. */
  48272. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48273. }
  48274. }
  48275. declare module BABYLON {
  48276. /**
  48277. * Defines the WindowsMotionController object that the state of the windows motion controller
  48278. */
  48279. export class WindowsMotionController extends WebVRController {
  48280. /**
  48281. * The base url used to load the left and right controller models
  48282. */
  48283. static MODEL_BASE_URL: string;
  48284. /**
  48285. * The name of the left controller model file
  48286. */
  48287. static MODEL_LEFT_FILENAME: string;
  48288. /**
  48289. * The name of the right controller model file
  48290. */
  48291. static MODEL_RIGHT_FILENAME: string;
  48292. /**
  48293. * The controller name prefix for this controller type
  48294. */
  48295. static readonly GAMEPAD_ID_PREFIX: string;
  48296. /**
  48297. * The controller id pattern for this controller type
  48298. */
  48299. private static readonly GAMEPAD_ID_PATTERN;
  48300. private _loadedMeshInfo;
  48301. protected readonly _mapping: {
  48302. buttons: string[];
  48303. buttonMeshNames: {
  48304. 'trigger': string;
  48305. 'menu': string;
  48306. 'grip': string;
  48307. 'thumbstick': string;
  48308. 'trackpad': string;
  48309. };
  48310. buttonObservableNames: {
  48311. 'trigger': string;
  48312. 'menu': string;
  48313. 'grip': string;
  48314. 'thumbstick': string;
  48315. 'trackpad': string;
  48316. };
  48317. axisMeshNames: string[];
  48318. pointingPoseMeshName: string;
  48319. };
  48320. /**
  48321. * Fired when the trackpad on this controller is clicked
  48322. */
  48323. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48324. /**
  48325. * Fired when the trackpad on this controller is modified
  48326. */
  48327. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48328. /**
  48329. * The current x and y values of this controller's trackpad
  48330. */
  48331. trackpad: StickValues;
  48332. /**
  48333. * Creates a new WindowsMotionController from a gamepad
  48334. * @param vrGamepad the gamepad that the controller should be created from
  48335. */
  48336. constructor(vrGamepad: any);
  48337. /**
  48338. * Fired when the trigger on this controller is modified
  48339. */
  48340. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48341. /**
  48342. * Fired when the menu button on this controller is modified
  48343. */
  48344. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48345. /**
  48346. * Fired when the grip button on this controller is modified
  48347. */
  48348. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48349. /**
  48350. * Fired when the thumbstick button on this controller is modified
  48351. */
  48352. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48353. /**
  48354. * Fired when the touchpad button on this controller is modified
  48355. */
  48356. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48357. /**
  48358. * Fired when the touchpad values on this controller are modified
  48359. */
  48360. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48361. protected _updateTrackpad(): void;
  48362. /**
  48363. * Called once per frame by the engine.
  48364. */
  48365. update(): void;
  48366. /**
  48367. * Called once for each button that changed state since the last frame
  48368. * @param buttonIdx Which button index changed
  48369. * @param state New state of the button
  48370. * @param changes Which properties on the state changed since last frame
  48371. */
  48372. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48373. /**
  48374. * Moves the buttons on the controller mesh based on their current state
  48375. * @param buttonName the name of the button to move
  48376. * @param buttonValue the value of the button which determines the buttons new position
  48377. */
  48378. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48379. /**
  48380. * Moves the axis on the controller mesh based on its current state
  48381. * @param axis the index of the axis
  48382. * @param axisValue the value of the axis which determines the meshes new position
  48383. * @hidden
  48384. */
  48385. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48386. /**
  48387. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48388. * @param scene scene in which to add meshes
  48389. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48390. */
  48391. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48392. /**
  48393. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48394. * can be transformed by button presses and axes values, based on this._mapping.
  48395. *
  48396. * @param scene scene in which the meshes exist
  48397. * @param meshes list of meshes that make up the controller model to process
  48398. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48399. */
  48400. private processModel;
  48401. private createMeshInfo;
  48402. /**
  48403. * Gets the ray of the controller in the direction the controller is pointing
  48404. * @param length the length the resulting ray should be
  48405. * @returns a ray in the direction the controller is pointing
  48406. */
  48407. getForwardRay(length?: number): Ray;
  48408. /**
  48409. * Disposes of the controller
  48410. */
  48411. dispose(): void;
  48412. }
  48413. /**
  48414. * This class represents a new windows motion controller in XR.
  48415. */
  48416. export class XRWindowsMotionController extends WindowsMotionController {
  48417. /**
  48418. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48419. */
  48420. protected readonly _mapping: {
  48421. buttons: string[];
  48422. buttonMeshNames: {
  48423. 'trigger': string;
  48424. 'menu': string;
  48425. 'grip': string;
  48426. 'thumbstick': string;
  48427. 'trackpad': string;
  48428. };
  48429. buttonObservableNames: {
  48430. 'trigger': string;
  48431. 'menu': string;
  48432. 'grip': string;
  48433. 'thumbstick': string;
  48434. 'trackpad': string;
  48435. };
  48436. axisMeshNames: string[];
  48437. pointingPoseMeshName: string;
  48438. };
  48439. /**
  48440. * Construct a new XR-Based windows motion controller
  48441. *
  48442. * @param gamepadInfo the gamepad object from the browser
  48443. */
  48444. constructor(gamepadInfo: any);
  48445. /**
  48446. * holds the thumbstick values (X,Y)
  48447. */
  48448. thumbstickValues: StickValues;
  48449. /**
  48450. * Fired when the thumbstick on this controller is clicked
  48451. */
  48452. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48453. /**
  48454. * Fired when the thumbstick on this controller is modified
  48455. */
  48456. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48457. /**
  48458. * Fired when the touchpad button on this controller is modified
  48459. */
  48460. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48461. /**
  48462. * Fired when the touchpad values on this controller are modified
  48463. */
  48464. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48465. /**
  48466. * Fired when the thumbstick button on this controller is modified
  48467. * here to prevent breaking changes
  48468. */
  48469. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48470. /**
  48471. * updating the thumbstick(!) and not the trackpad.
  48472. * This is named this way due to the difference between WebVR and XR and to avoid
  48473. * changing the parent class.
  48474. */
  48475. protected _updateTrackpad(): void;
  48476. /**
  48477. * Disposes the class with joy
  48478. */
  48479. dispose(): void;
  48480. }
  48481. }
  48482. declare module BABYLON {
  48483. /**
  48484. * Class containing static functions to help procedurally build meshes
  48485. */
  48486. export class PolyhedronBuilder {
  48487. /**
  48488. * Creates a polyhedron mesh
  48489. * * 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
  48490. * * The parameter `size` (positive float, default 1) sets the polygon size
  48491. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48492. * * 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`
  48493. * * 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
  48494. * * 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)`)
  48495. * * 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
  48496. * * 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
  48497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48498. * * 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
  48499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48500. * @param name defines the name of the mesh
  48501. * @param options defines the options used to create the mesh
  48502. * @param scene defines the hosting scene
  48503. * @returns the polyhedron mesh
  48504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48505. */
  48506. static CreatePolyhedron(name: string, options: {
  48507. type?: number;
  48508. size?: number;
  48509. sizeX?: number;
  48510. sizeY?: number;
  48511. sizeZ?: number;
  48512. custom?: any;
  48513. faceUV?: Vector4[];
  48514. faceColors?: Color4[];
  48515. flat?: boolean;
  48516. updatable?: boolean;
  48517. sideOrientation?: number;
  48518. frontUVs?: Vector4;
  48519. backUVs?: Vector4;
  48520. }, scene?: Nullable<Scene>): Mesh;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * Gizmo that enables scaling a mesh along 3 axis
  48526. */
  48527. export class ScaleGizmo extends Gizmo {
  48528. /**
  48529. * Internal gizmo used for interactions on the x axis
  48530. */
  48531. xGizmo: AxisScaleGizmo;
  48532. /**
  48533. * Internal gizmo used for interactions on the y axis
  48534. */
  48535. yGizmo: AxisScaleGizmo;
  48536. /**
  48537. * Internal gizmo used for interactions on the z axis
  48538. */
  48539. zGizmo: AxisScaleGizmo;
  48540. /**
  48541. * Internal gizmo used to scale all axis equally
  48542. */
  48543. uniformScaleGizmo: AxisScaleGizmo;
  48544. private _meshAttached;
  48545. private _updateGizmoRotationToMatchAttachedMesh;
  48546. private _snapDistance;
  48547. private _scaleRatio;
  48548. private _uniformScalingMesh;
  48549. private _octahedron;
  48550. private _sensitivity;
  48551. /** Fires an event when any of it's sub gizmos are dragged */
  48552. onDragStartObservable: Observable<unknown>;
  48553. /** Fires an event when any of it's sub gizmos are released from dragging */
  48554. onDragEndObservable: Observable<unknown>;
  48555. get attachedMesh(): Nullable<AbstractMesh>;
  48556. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48557. /**
  48558. * Creates a ScaleGizmo
  48559. * @param gizmoLayer The utility layer the gizmo will be added to
  48560. */
  48561. constructor(gizmoLayer?: UtilityLayerRenderer);
  48562. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48563. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48564. /**
  48565. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48566. */
  48567. set snapDistance(value: number);
  48568. get snapDistance(): number;
  48569. /**
  48570. * Ratio for the scale of the gizmo (Default: 1)
  48571. */
  48572. set scaleRatio(value: number);
  48573. get scaleRatio(): number;
  48574. /**
  48575. * Sensitivity factor for dragging (Default: 1)
  48576. */
  48577. set sensitivity(value: number);
  48578. get sensitivity(): number;
  48579. /**
  48580. * Disposes of the gizmo
  48581. */
  48582. dispose(): void;
  48583. }
  48584. }
  48585. declare module BABYLON {
  48586. /**
  48587. * Single axis scale gizmo
  48588. */
  48589. export class AxisScaleGizmo extends Gizmo {
  48590. /**
  48591. * Drag behavior responsible for the gizmos dragging interactions
  48592. */
  48593. dragBehavior: PointerDragBehavior;
  48594. private _pointerObserver;
  48595. /**
  48596. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48597. */
  48598. snapDistance: number;
  48599. /**
  48600. * Event that fires each time the gizmo snaps to a new location.
  48601. * * snapDistance is the the change in distance
  48602. */
  48603. onSnapObservable: Observable<{
  48604. snapDistance: number;
  48605. }>;
  48606. /**
  48607. * If the scaling operation should be done on all axis (default: false)
  48608. */
  48609. uniformScaling: boolean;
  48610. /**
  48611. * Custom sensitivity value for the drag strength
  48612. */
  48613. sensitivity: number;
  48614. private _isEnabled;
  48615. private _parent;
  48616. private _arrow;
  48617. private _coloredMaterial;
  48618. private _hoverMaterial;
  48619. /**
  48620. * Creates an AxisScaleGizmo
  48621. * @param gizmoLayer The utility layer the gizmo will be added to
  48622. * @param dragAxis The axis which the gizmo will be able to scale on
  48623. * @param color The color of the gizmo
  48624. */
  48625. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48626. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48627. /**
  48628. * If the gizmo is enabled
  48629. */
  48630. set isEnabled(value: boolean);
  48631. get isEnabled(): boolean;
  48632. /**
  48633. * Disposes of the gizmo
  48634. */
  48635. dispose(): void;
  48636. /**
  48637. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48638. * @param mesh The mesh to replace the default mesh of the gizmo
  48639. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48640. */
  48641. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48642. }
  48643. }
  48644. declare module BABYLON {
  48645. /**
  48646. * Bounding box gizmo
  48647. */
  48648. export class BoundingBoxGizmo extends Gizmo {
  48649. private _lineBoundingBox;
  48650. private _rotateSpheresParent;
  48651. private _scaleBoxesParent;
  48652. private _boundingDimensions;
  48653. private _renderObserver;
  48654. private _pointerObserver;
  48655. private _scaleDragSpeed;
  48656. private _tmpQuaternion;
  48657. private _tmpVector;
  48658. private _tmpRotationMatrix;
  48659. /**
  48660. * 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)
  48661. */
  48662. ignoreChildren: boolean;
  48663. /**
  48664. * 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)
  48665. */
  48666. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48667. /**
  48668. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48669. */
  48670. rotationSphereSize: number;
  48671. /**
  48672. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48673. */
  48674. scaleBoxSize: number;
  48675. /**
  48676. * 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)
  48677. */
  48678. fixedDragMeshScreenSize: boolean;
  48679. /**
  48680. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48681. */
  48682. fixedDragMeshScreenSizeDistanceFactor: number;
  48683. /**
  48684. * Fired when a rotation sphere or scale box is dragged
  48685. */
  48686. onDragStartObservable: Observable<{}>;
  48687. /**
  48688. * Fired when a scale box is dragged
  48689. */
  48690. onScaleBoxDragObservable: Observable<{}>;
  48691. /**
  48692. * Fired when a scale box drag is ended
  48693. */
  48694. onScaleBoxDragEndObservable: Observable<{}>;
  48695. /**
  48696. * Fired when a rotation sphere is dragged
  48697. */
  48698. onRotationSphereDragObservable: Observable<{}>;
  48699. /**
  48700. * Fired when a rotation sphere drag is ended
  48701. */
  48702. onRotationSphereDragEndObservable: Observable<{}>;
  48703. /**
  48704. * 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)
  48705. */
  48706. scalePivot: Nullable<Vector3>;
  48707. /**
  48708. * Mesh used as a pivot to rotate the attached mesh
  48709. */
  48710. private _anchorMesh;
  48711. private _existingMeshScale;
  48712. private _dragMesh;
  48713. private pointerDragBehavior;
  48714. private coloredMaterial;
  48715. private hoverColoredMaterial;
  48716. /**
  48717. * Sets the color of the bounding box gizmo
  48718. * @param color the color to set
  48719. */
  48720. setColor(color: Color3): void;
  48721. /**
  48722. * Creates an BoundingBoxGizmo
  48723. * @param gizmoLayer The utility layer the gizmo will be added to
  48724. * @param color The color of the gizmo
  48725. */
  48726. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48727. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48728. private _selectNode;
  48729. /**
  48730. * Updates the bounding box information for the Gizmo
  48731. */
  48732. updateBoundingBox(): void;
  48733. private _updateRotationSpheres;
  48734. private _updateScaleBoxes;
  48735. /**
  48736. * Enables rotation on the specified axis and disables rotation on the others
  48737. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48738. */
  48739. setEnabledRotationAxis(axis: string): void;
  48740. /**
  48741. * Enables/disables scaling
  48742. * @param enable if scaling should be enabled
  48743. */
  48744. setEnabledScaling(enable: boolean): void;
  48745. private _updateDummy;
  48746. /**
  48747. * Enables a pointer drag behavior on the bounding box of the gizmo
  48748. */
  48749. enableDragBehavior(): void;
  48750. /**
  48751. * Disposes of the gizmo
  48752. */
  48753. dispose(): void;
  48754. /**
  48755. * 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)
  48756. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48757. * @returns the bounding box mesh with the passed in mesh as a child
  48758. */
  48759. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48760. /**
  48761. * CustomMeshes are not supported by this gizmo
  48762. * @param mesh The mesh to replace the default mesh of the gizmo
  48763. */
  48764. setCustomMesh(mesh: Mesh): void;
  48765. }
  48766. }
  48767. declare module BABYLON {
  48768. /**
  48769. * Single plane rotation gizmo
  48770. */
  48771. export class PlaneRotationGizmo extends Gizmo {
  48772. /**
  48773. * Drag behavior responsible for the gizmos dragging interactions
  48774. */
  48775. dragBehavior: PointerDragBehavior;
  48776. private _pointerObserver;
  48777. /**
  48778. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48779. */
  48780. snapDistance: number;
  48781. /**
  48782. * Event that fires each time the gizmo snaps to a new location.
  48783. * * snapDistance is the the change in distance
  48784. */
  48785. onSnapObservable: Observable<{
  48786. snapDistance: number;
  48787. }>;
  48788. private _isEnabled;
  48789. private _parent;
  48790. /**
  48791. * Creates a PlaneRotationGizmo
  48792. * @param gizmoLayer The utility layer the gizmo will be added to
  48793. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48794. * @param color The color of the gizmo
  48795. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48796. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48797. */
  48798. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48799. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48800. /**
  48801. * If the gizmo is enabled
  48802. */
  48803. set isEnabled(value: boolean);
  48804. get isEnabled(): boolean;
  48805. /**
  48806. * Disposes of the gizmo
  48807. */
  48808. dispose(): void;
  48809. }
  48810. }
  48811. declare module BABYLON {
  48812. /**
  48813. * Gizmo that enables rotating a mesh along 3 axis
  48814. */
  48815. export class RotationGizmo extends Gizmo {
  48816. /**
  48817. * Internal gizmo used for interactions on the x axis
  48818. */
  48819. xGizmo: PlaneRotationGizmo;
  48820. /**
  48821. * Internal gizmo used for interactions on the y axis
  48822. */
  48823. yGizmo: PlaneRotationGizmo;
  48824. /**
  48825. * Internal gizmo used for interactions on the z axis
  48826. */
  48827. zGizmo: PlaneRotationGizmo;
  48828. /** Fires an event when any of it's sub gizmos are dragged */
  48829. onDragStartObservable: Observable<unknown>;
  48830. /** Fires an event when any of it's sub gizmos are released from dragging */
  48831. onDragEndObservable: Observable<unknown>;
  48832. private _meshAttached;
  48833. get attachedMesh(): Nullable<AbstractMesh>;
  48834. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48835. /**
  48836. * Creates a RotationGizmo
  48837. * @param gizmoLayer The utility layer the gizmo will be added to
  48838. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48839. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48840. */
  48841. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48842. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48843. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48844. /**
  48845. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48846. */
  48847. set snapDistance(value: number);
  48848. get snapDistance(): number;
  48849. /**
  48850. * Ratio for the scale of the gizmo (Default: 1)
  48851. */
  48852. set scaleRatio(value: number);
  48853. get scaleRatio(): number;
  48854. /**
  48855. * Disposes of the gizmo
  48856. */
  48857. dispose(): void;
  48858. /**
  48859. * CustomMeshes are not supported by this gizmo
  48860. * @param mesh The mesh to replace the default mesh of the gizmo
  48861. */
  48862. setCustomMesh(mesh: Mesh): void;
  48863. }
  48864. }
  48865. declare module BABYLON {
  48866. /**
  48867. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48868. */
  48869. export class GizmoManager implements IDisposable {
  48870. private scene;
  48871. /**
  48872. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48873. */
  48874. gizmos: {
  48875. positionGizmo: Nullable<PositionGizmo>;
  48876. rotationGizmo: Nullable<RotationGizmo>;
  48877. scaleGizmo: Nullable<ScaleGizmo>;
  48878. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48879. };
  48880. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48881. clearGizmoOnEmptyPointerEvent: boolean;
  48882. /** Fires an event when the manager is attached to a mesh */
  48883. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48884. private _gizmosEnabled;
  48885. private _pointerObserver;
  48886. private _attachedMesh;
  48887. private _boundingBoxColor;
  48888. private _defaultUtilityLayer;
  48889. private _defaultKeepDepthUtilityLayer;
  48890. /**
  48891. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48892. */
  48893. boundingBoxDragBehavior: SixDofDragBehavior;
  48894. /**
  48895. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48896. */
  48897. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48898. /**
  48899. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48900. */
  48901. usePointerToAttachGizmos: boolean;
  48902. /**
  48903. * Utility layer that the bounding box gizmo belongs to
  48904. */
  48905. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48906. /**
  48907. * Utility layer that all gizmos besides bounding box belong to
  48908. */
  48909. get utilityLayer(): UtilityLayerRenderer;
  48910. /**
  48911. * Instatiates a gizmo manager
  48912. * @param scene the scene to overlay the gizmos on top of
  48913. */
  48914. constructor(scene: Scene);
  48915. /**
  48916. * Attaches a set of gizmos to the specified mesh
  48917. * @param mesh The mesh the gizmo's should be attached to
  48918. */
  48919. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48920. /**
  48921. * If the position gizmo is enabled
  48922. */
  48923. set positionGizmoEnabled(value: boolean);
  48924. get positionGizmoEnabled(): boolean;
  48925. /**
  48926. * If the rotation gizmo is enabled
  48927. */
  48928. set rotationGizmoEnabled(value: boolean);
  48929. get rotationGizmoEnabled(): boolean;
  48930. /**
  48931. * If the scale gizmo is enabled
  48932. */
  48933. set scaleGizmoEnabled(value: boolean);
  48934. get scaleGizmoEnabled(): boolean;
  48935. /**
  48936. * If the boundingBox gizmo is enabled
  48937. */
  48938. set boundingBoxGizmoEnabled(value: boolean);
  48939. get boundingBoxGizmoEnabled(): boolean;
  48940. /**
  48941. * Disposes of the gizmo manager
  48942. */
  48943. dispose(): void;
  48944. }
  48945. }
  48946. declare module BABYLON {
  48947. /**
  48948. * A directional light is defined by a direction (what a surprise!).
  48949. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48950. * 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.
  48951. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48952. */
  48953. export class DirectionalLight extends ShadowLight {
  48954. private _shadowFrustumSize;
  48955. /**
  48956. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48957. */
  48958. get shadowFrustumSize(): number;
  48959. /**
  48960. * Specifies a fix frustum size for the shadow generation.
  48961. */
  48962. set shadowFrustumSize(value: number);
  48963. private _shadowOrthoScale;
  48964. /**
  48965. * Gets the shadow projection scale against the optimal computed one.
  48966. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48967. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48968. */
  48969. get shadowOrthoScale(): number;
  48970. /**
  48971. * Sets the shadow projection scale against the optimal computed one.
  48972. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48973. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48974. */
  48975. set shadowOrthoScale(value: number);
  48976. /**
  48977. * Automatically compute the projection matrix to best fit (including all the casters)
  48978. * on each frame.
  48979. */
  48980. autoUpdateExtends: boolean;
  48981. /**
  48982. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48983. * on each frame. autoUpdateExtends must be set to true for this to work
  48984. */
  48985. autoCalcShadowZBounds: boolean;
  48986. private _orthoLeft;
  48987. private _orthoRight;
  48988. private _orthoTop;
  48989. private _orthoBottom;
  48990. /**
  48991. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48992. * The directional light is emitted from everywhere in the given direction.
  48993. * It can cast shadows.
  48994. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48995. * @param name The friendly name of the light
  48996. * @param direction The direction of the light
  48997. * @param scene The scene the light belongs to
  48998. */
  48999. constructor(name: string, direction: Vector3, scene: Scene);
  49000. /**
  49001. * Returns the string "DirectionalLight".
  49002. * @return The class name
  49003. */
  49004. getClassName(): string;
  49005. /**
  49006. * Returns the integer 1.
  49007. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49008. */
  49009. getTypeID(): number;
  49010. /**
  49011. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49012. * Returns the DirectionalLight Shadow projection matrix.
  49013. */
  49014. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49015. /**
  49016. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49017. * Returns the DirectionalLight Shadow projection matrix.
  49018. */
  49019. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49020. /**
  49021. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49022. * Returns the DirectionalLight Shadow projection matrix.
  49023. */
  49024. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49025. protected _buildUniformLayout(): void;
  49026. /**
  49027. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49028. * @param effect The effect to update
  49029. * @param lightIndex The index of the light in the effect to update
  49030. * @returns The directional light
  49031. */
  49032. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49033. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49034. /**
  49035. * Gets the minZ used for shadow according to both the scene and the light.
  49036. *
  49037. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49038. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49039. * @param activeCamera The camera we are returning the min for
  49040. * @returns the depth min z
  49041. */
  49042. getDepthMinZ(activeCamera: Camera): number;
  49043. /**
  49044. * Gets the maxZ used for shadow according to both the scene and the light.
  49045. *
  49046. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49047. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49048. * @param activeCamera The camera we are returning the max for
  49049. * @returns the depth max z
  49050. */
  49051. getDepthMaxZ(activeCamera: Camera): number;
  49052. /**
  49053. * Prepares the list of defines specific to the light type.
  49054. * @param defines the list of defines
  49055. * @param lightIndex defines the index of the light for the effect
  49056. */
  49057. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49058. }
  49059. }
  49060. declare module BABYLON {
  49061. /**
  49062. * Class containing static functions to help procedurally build meshes
  49063. */
  49064. export class HemisphereBuilder {
  49065. /**
  49066. * Creates a hemisphere mesh
  49067. * @param name defines the name of the mesh
  49068. * @param options defines the options used to create the mesh
  49069. * @param scene defines the hosting scene
  49070. * @returns the hemisphere mesh
  49071. */
  49072. static CreateHemisphere(name: string, options: {
  49073. segments?: number;
  49074. diameter?: number;
  49075. sideOrientation?: number;
  49076. }, scene: any): Mesh;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /**
  49081. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49082. * These values define a cone of light starting from the position, emitting toward the direction.
  49083. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49084. * and the exponent defines the speed of the decay of the light with distance (reach).
  49085. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49086. */
  49087. export class SpotLight extends ShadowLight {
  49088. private _angle;
  49089. private _innerAngle;
  49090. private _cosHalfAngle;
  49091. private _lightAngleScale;
  49092. private _lightAngleOffset;
  49093. /**
  49094. * Gets the cone angle of the spot light in Radians.
  49095. */
  49096. get angle(): number;
  49097. /**
  49098. * Sets the cone angle of the spot light in Radians.
  49099. */
  49100. set angle(value: number);
  49101. /**
  49102. * Only used in gltf falloff mode, this defines the angle where
  49103. * the directional falloff will start before cutting at angle which could be seen
  49104. * as outer angle.
  49105. */
  49106. get innerAngle(): number;
  49107. /**
  49108. * Only used in gltf falloff mode, this defines the angle where
  49109. * the directional falloff will start before cutting at angle which could be seen
  49110. * as outer angle.
  49111. */
  49112. set innerAngle(value: number);
  49113. private _shadowAngleScale;
  49114. /**
  49115. * Allows scaling the angle of the light for shadow generation only.
  49116. */
  49117. get shadowAngleScale(): number;
  49118. /**
  49119. * Allows scaling the angle of the light for shadow generation only.
  49120. */
  49121. set shadowAngleScale(value: number);
  49122. /**
  49123. * The light decay speed with the distance from the emission spot.
  49124. */
  49125. exponent: number;
  49126. private _projectionTextureMatrix;
  49127. /**
  49128. * Allows reading the projecton texture
  49129. */
  49130. get projectionTextureMatrix(): Matrix;
  49131. protected _projectionTextureLightNear: number;
  49132. /**
  49133. * Gets the near clip of the Spotlight for texture projection.
  49134. */
  49135. get projectionTextureLightNear(): number;
  49136. /**
  49137. * Sets the near clip of the Spotlight for texture projection.
  49138. */
  49139. set projectionTextureLightNear(value: number);
  49140. protected _projectionTextureLightFar: number;
  49141. /**
  49142. * Gets the far clip of the Spotlight for texture projection.
  49143. */
  49144. get projectionTextureLightFar(): number;
  49145. /**
  49146. * Sets the far clip of the Spotlight for texture projection.
  49147. */
  49148. set projectionTextureLightFar(value: number);
  49149. protected _projectionTextureUpDirection: Vector3;
  49150. /**
  49151. * Gets the Up vector of the Spotlight for texture projection.
  49152. */
  49153. get projectionTextureUpDirection(): Vector3;
  49154. /**
  49155. * Sets the Up vector of the Spotlight for texture projection.
  49156. */
  49157. set projectionTextureUpDirection(value: Vector3);
  49158. private _projectionTexture;
  49159. /**
  49160. * Gets the projection texture of the light.
  49161. */
  49162. get projectionTexture(): Nullable<BaseTexture>;
  49163. /**
  49164. * Sets the projection texture of the light.
  49165. */
  49166. set projectionTexture(value: Nullable<BaseTexture>);
  49167. private _projectionTextureViewLightDirty;
  49168. private _projectionTextureProjectionLightDirty;
  49169. private _projectionTextureDirty;
  49170. private _projectionTextureViewTargetVector;
  49171. private _projectionTextureViewLightMatrix;
  49172. private _projectionTextureProjectionLightMatrix;
  49173. private _projectionTextureScalingMatrix;
  49174. /**
  49175. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49176. * It can cast shadows.
  49177. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49178. * @param name The light friendly name
  49179. * @param position The position of the spot light in the scene
  49180. * @param direction The direction of the light in the scene
  49181. * @param angle The cone angle of the light in Radians
  49182. * @param exponent The light decay speed with the distance from the emission spot
  49183. * @param scene The scene the lights belongs to
  49184. */
  49185. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49186. /**
  49187. * Returns the string "SpotLight".
  49188. * @returns the class name
  49189. */
  49190. getClassName(): string;
  49191. /**
  49192. * Returns the integer 2.
  49193. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49194. */
  49195. getTypeID(): number;
  49196. /**
  49197. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49198. */
  49199. protected _setDirection(value: Vector3): void;
  49200. /**
  49201. * Overrides the position setter to recompute the projection texture view light Matrix.
  49202. */
  49203. protected _setPosition(value: Vector3): void;
  49204. /**
  49205. * 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.
  49206. * Returns the SpotLight.
  49207. */
  49208. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49209. protected _computeProjectionTextureViewLightMatrix(): void;
  49210. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49211. /**
  49212. * Main function for light texture projection matrix computing.
  49213. */
  49214. protected _computeProjectionTextureMatrix(): void;
  49215. protected _buildUniformLayout(): void;
  49216. private _computeAngleValues;
  49217. /**
  49218. * Sets the passed Effect "effect" with the Light textures.
  49219. * @param effect The effect to update
  49220. * @param lightIndex The index of the light in the effect to update
  49221. * @returns The light
  49222. */
  49223. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49224. /**
  49225. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49226. * @param effect The effect to update
  49227. * @param lightIndex The index of the light in the effect to update
  49228. * @returns The spot light
  49229. */
  49230. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49231. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49232. /**
  49233. * Disposes the light and the associated resources.
  49234. */
  49235. dispose(): void;
  49236. /**
  49237. * Prepares the list of defines specific to the light type.
  49238. * @param defines the list of defines
  49239. * @param lightIndex defines the index of the light for the effect
  49240. */
  49241. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49242. }
  49243. }
  49244. declare module BABYLON {
  49245. /**
  49246. * Gizmo that enables viewing a light
  49247. */
  49248. export class LightGizmo extends Gizmo {
  49249. private _lightMesh;
  49250. private _material;
  49251. private _cachedPosition;
  49252. private _cachedForward;
  49253. private _attachedMeshParent;
  49254. /**
  49255. * Creates a LightGizmo
  49256. * @param gizmoLayer The utility layer the gizmo will be added to
  49257. */
  49258. constructor(gizmoLayer?: UtilityLayerRenderer);
  49259. private _light;
  49260. /**
  49261. * The light that the gizmo is attached to
  49262. */
  49263. set light(light: Nullable<Light>);
  49264. get light(): Nullable<Light>;
  49265. /**
  49266. * Gets the material used to render the light gizmo
  49267. */
  49268. get material(): StandardMaterial;
  49269. /**
  49270. * @hidden
  49271. * Updates the gizmo to match the attached mesh's position/rotation
  49272. */
  49273. protected _update(): void;
  49274. private static _Scale;
  49275. /**
  49276. * Creates the lines for a light mesh
  49277. */
  49278. private static _CreateLightLines;
  49279. /**
  49280. * Disposes of the light gizmo
  49281. */
  49282. dispose(): void;
  49283. private static _CreateHemisphericLightMesh;
  49284. private static _CreatePointLightMesh;
  49285. private static _CreateSpotLightMesh;
  49286. private static _CreateDirectionalLightMesh;
  49287. }
  49288. }
  49289. declare module BABYLON {
  49290. /** @hidden */
  49291. export var backgroundFragmentDeclaration: {
  49292. name: string;
  49293. shader: string;
  49294. };
  49295. }
  49296. declare module BABYLON {
  49297. /** @hidden */
  49298. export var backgroundUboDeclaration: {
  49299. name: string;
  49300. shader: string;
  49301. };
  49302. }
  49303. declare module BABYLON {
  49304. /** @hidden */
  49305. export var backgroundPixelShader: {
  49306. name: string;
  49307. shader: string;
  49308. };
  49309. }
  49310. declare module BABYLON {
  49311. /** @hidden */
  49312. export var backgroundVertexDeclaration: {
  49313. name: string;
  49314. shader: string;
  49315. };
  49316. }
  49317. declare module BABYLON {
  49318. /** @hidden */
  49319. export var backgroundVertexShader: {
  49320. name: string;
  49321. shader: string;
  49322. };
  49323. }
  49324. declare module BABYLON {
  49325. /**
  49326. * Background material used to create an efficient environement around your scene.
  49327. */
  49328. export class BackgroundMaterial extends PushMaterial {
  49329. /**
  49330. * Standard reflectance value at parallel view angle.
  49331. */
  49332. static StandardReflectance0: number;
  49333. /**
  49334. * Standard reflectance value at grazing angle.
  49335. */
  49336. static StandardReflectance90: number;
  49337. protected _primaryColor: Color3;
  49338. /**
  49339. * Key light Color (multiply against the environement texture)
  49340. */
  49341. primaryColor: Color3;
  49342. protected __perceptualColor: Nullable<Color3>;
  49343. /**
  49344. * Experimental Internal Use Only.
  49345. *
  49346. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49347. * This acts as a helper to set the primary color to a more "human friendly" value.
  49348. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49349. * output color as close as possible from the chosen value.
  49350. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49351. * part of lighting setup.)
  49352. */
  49353. get _perceptualColor(): Nullable<Color3>;
  49354. set _perceptualColor(value: Nullable<Color3>);
  49355. protected _primaryColorShadowLevel: float;
  49356. /**
  49357. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49358. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49359. */
  49360. get primaryColorShadowLevel(): float;
  49361. set primaryColorShadowLevel(value: float);
  49362. protected _primaryColorHighlightLevel: float;
  49363. /**
  49364. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49365. * The primary color is used at the level chosen to define what the white area would look.
  49366. */
  49367. get primaryColorHighlightLevel(): float;
  49368. set primaryColorHighlightLevel(value: float);
  49369. protected _reflectionTexture: Nullable<BaseTexture>;
  49370. /**
  49371. * Reflection Texture used in the material.
  49372. * Should be author in a specific way for the best result (refer to the documentation).
  49373. */
  49374. reflectionTexture: Nullable<BaseTexture>;
  49375. protected _reflectionBlur: float;
  49376. /**
  49377. * Reflection Texture level of blur.
  49378. *
  49379. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49380. * texture twice.
  49381. */
  49382. reflectionBlur: float;
  49383. protected _diffuseTexture: Nullable<BaseTexture>;
  49384. /**
  49385. * Diffuse Texture used in the material.
  49386. * Should be author in a specific way for the best result (refer to the documentation).
  49387. */
  49388. diffuseTexture: Nullable<BaseTexture>;
  49389. protected _shadowLights: Nullable<IShadowLight[]>;
  49390. /**
  49391. * Specify the list of lights casting shadow on the material.
  49392. * All scene shadow lights will be included if null.
  49393. */
  49394. shadowLights: Nullable<IShadowLight[]>;
  49395. protected _shadowLevel: float;
  49396. /**
  49397. * Helps adjusting the shadow to a softer level if required.
  49398. * 0 means black shadows and 1 means no shadows.
  49399. */
  49400. shadowLevel: float;
  49401. protected _sceneCenter: Vector3;
  49402. /**
  49403. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49404. * It is usually zero but might be interesting to modify according to your setup.
  49405. */
  49406. sceneCenter: Vector3;
  49407. protected _opacityFresnel: boolean;
  49408. /**
  49409. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49410. * This helps ensuring a nice transition when the camera goes under the ground.
  49411. */
  49412. opacityFresnel: boolean;
  49413. protected _reflectionFresnel: boolean;
  49414. /**
  49415. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49416. * This helps adding a mirror texture on the ground.
  49417. */
  49418. reflectionFresnel: boolean;
  49419. protected _reflectionFalloffDistance: number;
  49420. /**
  49421. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49422. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49423. */
  49424. reflectionFalloffDistance: number;
  49425. protected _reflectionAmount: number;
  49426. /**
  49427. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49428. */
  49429. reflectionAmount: number;
  49430. protected _reflectionReflectance0: number;
  49431. /**
  49432. * This specifies the weight of the reflection at grazing angle.
  49433. */
  49434. reflectionReflectance0: number;
  49435. protected _reflectionReflectance90: number;
  49436. /**
  49437. * This specifies the weight of the reflection at a perpendicular point of view.
  49438. */
  49439. reflectionReflectance90: number;
  49440. /**
  49441. * Sets the reflection reflectance fresnel values according to the default standard
  49442. * empirically know to work well :-)
  49443. */
  49444. set reflectionStandardFresnelWeight(value: number);
  49445. protected _useRGBColor: boolean;
  49446. /**
  49447. * Helps to directly use the maps channels instead of their level.
  49448. */
  49449. useRGBColor: boolean;
  49450. protected _enableNoise: boolean;
  49451. /**
  49452. * This helps reducing the banding effect that could occur on the background.
  49453. */
  49454. enableNoise: boolean;
  49455. /**
  49456. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49457. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49458. * Recommended to be keep at 1.0 except for special cases.
  49459. */
  49460. get fovMultiplier(): number;
  49461. set fovMultiplier(value: number);
  49462. private _fovMultiplier;
  49463. /**
  49464. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49465. */
  49466. useEquirectangularFOV: boolean;
  49467. private _maxSimultaneousLights;
  49468. /**
  49469. * Number of Simultaneous lights allowed on the material.
  49470. */
  49471. maxSimultaneousLights: int;
  49472. /**
  49473. * Default configuration related to image processing available in the Background Material.
  49474. */
  49475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49476. /**
  49477. * Keep track of the image processing observer to allow dispose and replace.
  49478. */
  49479. private _imageProcessingObserver;
  49480. /**
  49481. * Attaches a new image processing configuration to the PBR Material.
  49482. * @param configuration (if null the scene configuration will be use)
  49483. */
  49484. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49485. /**
  49486. * Gets the image processing configuration used either in this material.
  49487. */
  49488. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49489. /**
  49490. * Sets the Default image processing configuration used either in the this material.
  49491. *
  49492. * If sets to null, the scene one is in use.
  49493. */
  49494. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49495. /**
  49496. * Gets wether the color curves effect is enabled.
  49497. */
  49498. get cameraColorCurvesEnabled(): boolean;
  49499. /**
  49500. * Sets wether the color curves effect is enabled.
  49501. */
  49502. set cameraColorCurvesEnabled(value: boolean);
  49503. /**
  49504. * Gets wether the color grading effect is enabled.
  49505. */
  49506. get cameraColorGradingEnabled(): boolean;
  49507. /**
  49508. * Gets wether the color grading effect is enabled.
  49509. */
  49510. set cameraColorGradingEnabled(value: boolean);
  49511. /**
  49512. * Gets wether tonemapping is enabled or not.
  49513. */
  49514. get cameraToneMappingEnabled(): boolean;
  49515. /**
  49516. * Sets wether tonemapping is enabled or not
  49517. */
  49518. set cameraToneMappingEnabled(value: boolean);
  49519. /**
  49520. * The camera exposure used on this material.
  49521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49522. * This corresponds to a photographic exposure.
  49523. */
  49524. get cameraExposure(): float;
  49525. /**
  49526. * The camera exposure used on this material.
  49527. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49528. * This corresponds to a photographic exposure.
  49529. */
  49530. set cameraExposure(value: float);
  49531. /**
  49532. * Gets The camera contrast used on this material.
  49533. */
  49534. get cameraContrast(): float;
  49535. /**
  49536. * Sets The camera contrast used on this material.
  49537. */
  49538. set cameraContrast(value: float);
  49539. /**
  49540. * Gets the Color Grading 2D Lookup Texture.
  49541. */
  49542. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49543. /**
  49544. * Sets the Color Grading 2D Lookup Texture.
  49545. */
  49546. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49547. /**
  49548. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49549. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49550. * 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;
  49551. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49552. */
  49553. get cameraColorCurves(): Nullable<ColorCurves>;
  49554. /**
  49555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49557. * 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;
  49558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49559. */
  49560. set cameraColorCurves(value: Nullable<ColorCurves>);
  49561. /**
  49562. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49563. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49564. */
  49565. switchToBGR: boolean;
  49566. private _renderTargets;
  49567. private _reflectionControls;
  49568. private _white;
  49569. private _primaryShadowColor;
  49570. private _primaryHighlightColor;
  49571. /**
  49572. * Instantiates a Background Material in the given scene
  49573. * @param name The friendly name of the material
  49574. * @param scene The scene to add the material to
  49575. */
  49576. constructor(name: string, scene: Scene);
  49577. /**
  49578. * Gets a boolean indicating that current material needs to register RTT
  49579. */
  49580. get hasRenderTargetTextures(): boolean;
  49581. /**
  49582. * The entire material has been created in order to prevent overdraw.
  49583. * @returns false
  49584. */
  49585. needAlphaTesting(): boolean;
  49586. /**
  49587. * The entire material has been created in order to prevent overdraw.
  49588. * @returns true if blending is enable
  49589. */
  49590. needAlphaBlending(): boolean;
  49591. /**
  49592. * Checks wether the material is ready to be rendered for a given mesh.
  49593. * @param mesh The mesh to render
  49594. * @param subMesh The submesh to check against
  49595. * @param useInstances Specify wether or not the material is used with instances
  49596. * @returns true if all the dependencies are ready (Textures, Effects...)
  49597. */
  49598. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49599. /**
  49600. * Compute the primary color according to the chosen perceptual color.
  49601. */
  49602. private _computePrimaryColorFromPerceptualColor;
  49603. /**
  49604. * Compute the highlights and shadow colors according to their chosen levels.
  49605. */
  49606. private _computePrimaryColors;
  49607. /**
  49608. * Build the uniform buffer used in the material.
  49609. */
  49610. buildUniformLayout(): void;
  49611. /**
  49612. * Unbind the material.
  49613. */
  49614. unbind(): void;
  49615. /**
  49616. * Bind only the world matrix to the material.
  49617. * @param world The world matrix to bind.
  49618. */
  49619. bindOnlyWorldMatrix(world: Matrix): void;
  49620. /**
  49621. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49622. * @param world The world matrix to bind.
  49623. * @param subMesh The submesh to bind for.
  49624. */
  49625. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49626. /**
  49627. * Checks to see if a texture is used in the material.
  49628. * @param texture - Base texture to use.
  49629. * @returns - Boolean specifying if a texture is used in the material.
  49630. */
  49631. hasTexture(texture: BaseTexture): boolean;
  49632. /**
  49633. * Dispose the material.
  49634. * @param forceDisposeEffect Force disposal of the associated effect.
  49635. * @param forceDisposeTextures Force disposal of the associated textures.
  49636. */
  49637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49638. /**
  49639. * Clones the material.
  49640. * @param name The cloned name.
  49641. * @returns The cloned material.
  49642. */
  49643. clone(name: string): BackgroundMaterial;
  49644. /**
  49645. * Serializes the current material to its JSON representation.
  49646. * @returns The JSON representation.
  49647. */
  49648. serialize(): any;
  49649. /**
  49650. * Gets the class name of the material
  49651. * @returns "BackgroundMaterial"
  49652. */
  49653. getClassName(): string;
  49654. /**
  49655. * Parse a JSON input to create back a background material.
  49656. * @param source The JSON data to parse
  49657. * @param scene The scene to create the parsed material in
  49658. * @param rootUrl The root url of the assets the material depends upon
  49659. * @returns the instantiated BackgroundMaterial.
  49660. */
  49661. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49662. }
  49663. }
  49664. declare module BABYLON {
  49665. /**
  49666. * Represents the different options available during the creation of
  49667. * a Environment helper.
  49668. *
  49669. * This can control the default ground, skybox and image processing setup of your scene.
  49670. */
  49671. export interface IEnvironmentHelperOptions {
  49672. /**
  49673. * Specifies whether or not to create a ground.
  49674. * True by default.
  49675. */
  49676. createGround: boolean;
  49677. /**
  49678. * Specifies the ground size.
  49679. * 15 by default.
  49680. */
  49681. groundSize: number;
  49682. /**
  49683. * The texture used on the ground for the main color.
  49684. * Comes from the BabylonJS CDN by default.
  49685. *
  49686. * Remarks: Can be either a texture or a url.
  49687. */
  49688. groundTexture: string | BaseTexture;
  49689. /**
  49690. * The color mixed in the ground texture by default.
  49691. * BabylonJS clearColor by default.
  49692. */
  49693. groundColor: Color3;
  49694. /**
  49695. * Specifies the ground opacity.
  49696. * 1 by default.
  49697. */
  49698. groundOpacity: number;
  49699. /**
  49700. * Enables the ground to receive shadows.
  49701. * True by default.
  49702. */
  49703. enableGroundShadow: boolean;
  49704. /**
  49705. * Helps preventing the shadow to be fully black on the ground.
  49706. * 0.5 by default.
  49707. */
  49708. groundShadowLevel: number;
  49709. /**
  49710. * Creates a mirror texture attach to the ground.
  49711. * false by default.
  49712. */
  49713. enableGroundMirror: boolean;
  49714. /**
  49715. * Specifies the ground mirror size ratio.
  49716. * 0.3 by default as the default kernel is 64.
  49717. */
  49718. groundMirrorSizeRatio: number;
  49719. /**
  49720. * Specifies the ground mirror blur kernel size.
  49721. * 64 by default.
  49722. */
  49723. groundMirrorBlurKernel: number;
  49724. /**
  49725. * Specifies the ground mirror visibility amount.
  49726. * 1 by default
  49727. */
  49728. groundMirrorAmount: number;
  49729. /**
  49730. * Specifies the ground mirror reflectance weight.
  49731. * This uses the standard weight of the background material to setup the fresnel effect
  49732. * of the mirror.
  49733. * 1 by default.
  49734. */
  49735. groundMirrorFresnelWeight: number;
  49736. /**
  49737. * Specifies the ground mirror Falloff distance.
  49738. * This can helps reducing the size of the reflection.
  49739. * 0 by Default.
  49740. */
  49741. groundMirrorFallOffDistance: number;
  49742. /**
  49743. * Specifies the ground mirror texture type.
  49744. * Unsigned Int by Default.
  49745. */
  49746. groundMirrorTextureType: number;
  49747. /**
  49748. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49749. * the shown objects.
  49750. */
  49751. groundYBias: number;
  49752. /**
  49753. * Specifies whether or not to create a skybox.
  49754. * True by default.
  49755. */
  49756. createSkybox: boolean;
  49757. /**
  49758. * Specifies the skybox size.
  49759. * 20 by default.
  49760. */
  49761. skyboxSize: number;
  49762. /**
  49763. * The texture used on the skybox for the main color.
  49764. * Comes from the BabylonJS CDN by default.
  49765. *
  49766. * Remarks: Can be either a texture or a url.
  49767. */
  49768. skyboxTexture: string | BaseTexture;
  49769. /**
  49770. * The color mixed in the skybox texture by default.
  49771. * BabylonJS clearColor by default.
  49772. */
  49773. skyboxColor: Color3;
  49774. /**
  49775. * The background rotation around the Y axis of the scene.
  49776. * This helps aligning the key lights of your scene with the background.
  49777. * 0 by default.
  49778. */
  49779. backgroundYRotation: number;
  49780. /**
  49781. * Compute automatically the size of the elements to best fit with the scene.
  49782. */
  49783. sizeAuto: boolean;
  49784. /**
  49785. * Default position of the rootMesh if autoSize is not true.
  49786. */
  49787. rootPosition: Vector3;
  49788. /**
  49789. * Sets up the image processing in the scene.
  49790. * true by default.
  49791. */
  49792. setupImageProcessing: boolean;
  49793. /**
  49794. * The texture used as your environment texture in the scene.
  49795. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49796. *
  49797. * Remarks: Can be either a texture or a url.
  49798. */
  49799. environmentTexture: string | BaseTexture;
  49800. /**
  49801. * The value of the exposure to apply to the scene.
  49802. * 0.6 by default if setupImageProcessing is true.
  49803. */
  49804. cameraExposure: number;
  49805. /**
  49806. * The value of the contrast to apply to the scene.
  49807. * 1.6 by default if setupImageProcessing is true.
  49808. */
  49809. cameraContrast: number;
  49810. /**
  49811. * Specifies whether or not tonemapping should be enabled in the scene.
  49812. * true by default if setupImageProcessing is true.
  49813. */
  49814. toneMappingEnabled: boolean;
  49815. }
  49816. /**
  49817. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49818. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49819. * It also helps with the default setup of your imageProcessing configuration.
  49820. */
  49821. export class EnvironmentHelper {
  49822. /**
  49823. * Default ground texture URL.
  49824. */
  49825. private static _groundTextureCDNUrl;
  49826. /**
  49827. * Default skybox texture URL.
  49828. */
  49829. private static _skyboxTextureCDNUrl;
  49830. /**
  49831. * Default environment texture URL.
  49832. */
  49833. private static _environmentTextureCDNUrl;
  49834. /**
  49835. * Creates the default options for the helper.
  49836. */
  49837. private static _getDefaultOptions;
  49838. private _rootMesh;
  49839. /**
  49840. * Gets the root mesh created by the helper.
  49841. */
  49842. get rootMesh(): Mesh;
  49843. private _skybox;
  49844. /**
  49845. * Gets the skybox created by the helper.
  49846. */
  49847. get skybox(): Nullable<Mesh>;
  49848. private _skyboxTexture;
  49849. /**
  49850. * Gets the skybox texture created by the helper.
  49851. */
  49852. get skyboxTexture(): Nullable<BaseTexture>;
  49853. private _skyboxMaterial;
  49854. /**
  49855. * Gets the skybox material created by the helper.
  49856. */
  49857. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49858. private _ground;
  49859. /**
  49860. * Gets the ground mesh created by the helper.
  49861. */
  49862. get ground(): Nullable<Mesh>;
  49863. private _groundTexture;
  49864. /**
  49865. * Gets the ground texture created by the helper.
  49866. */
  49867. get groundTexture(): Nullable<BaseTexture>;
  49868. private _groundMirror;
  49869. /**
  49870. * Gets the ground mirror created by the helper.
  49871. */
  49872. get groundMirror(): Nullable<MirrorTexture>;
  49873. /**
  49874. * Gets the ground mirror render list to helps pushing the meshes
  49875. * you wish in the ground reflection.
  49876. */
  49877. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49878. private _groundMaterial;
  49879. /**
  49880. * Gets the ground material created by the helper.
  49881. */
  49882. get groundMaterial(): Nullable<BackgroundMaterial>;
  49883. /**
  49884. * Stores the creation options.
  49885. */
  49886. private readonly _scene;
  49887. private _options;
  49888. /**
  49889. * This observable will be notified with any error during the creation of the environment,
  49890. * mainly texture creation errors.
  49891. */
  49892. onErrorObservable: Observable<{
  49893. message?: string;
  49894. exception?: any;
  49895. }>;
  49896. /**
  49897. * constructor
  49898. * @param options Defines the options we want to customize the helper
  49899. * @param scene The scene to add the material to
  49900. */
  49901. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49902. /**
  49903. * Updates the background according to the new options
  49904. * @param options
  49905. */
  49906. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49907. /**
  49908. * Sets the primary color of all the available elements.
  49909. * @param color the main color to affect to the ground and the background
  49910. */
  49911. setMainColor(color: Color3): void;
  49912. /**
  49913. * Setup the image processing according to the specified options.
  49914. */
  49915. private _setupImageProcessing;
  49916. /**
  49917. * Setup the environment texture according to the specified options.
  49918. */
  49919. private _setupEnvironmentTexture;
  49920. /**
  49921. * Setup the background according to the specified options.
  49922. */
  49923. private _setupBackground;
  49924. /**
  49925. * Get the scene sizes according to the setup.
  49926. */
  49927. private _getSceneSize;
  49928. /**
  49929. * Setup the ground according to the specified options.
  49930. */
  49931. private _setupGround;
  49932. /**
  49933. * Setup the ground material according to the specified options.
  49934. */
  49935. private _setupGroundMaterial;
  49936. /**
  49937. * Setup the ground diffuse texture according to the specified options.
  49938. */
  49939. private _setupGroundDiffuseTexture;
  49940. /**
  49941. * Setup the ground mirror texture according to the specified options.
  49942. */
  49943. private _setupGroundMirrorTexture;
  49944. /**
  49945. * Setup the ground to receive the mirror texture.
  49946. */
  49947. private _setupMirrorInGroundMaterial;
  49948. /**
  49949. * Setup the skybox according to the specified options.
  49950. */
  49951. private _setupSkybox;
  49952. /**
  49953. * Setup the skybox material according to the specified options.
  49954. */
  49955. private _setupSkyboxMaterial;
  49956. /**
  49957. * Setup the skybox reflection texture according to the specified options.
  49958. */
  49959. private _setupSkyboxReflectionTexture;
  49960. private _errorHandler;
  49961. /**
  49962. * Dispose all the elements created by the Helper.
  49963. */
  49964. dispose(): void;
  49965. }
  49966. }
  49967. declare module BABYLON {
  49968. /**
  49969. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49970. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49971. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49972. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49973. */
  49974. export class PhotoDome extends TransformNode {
  49975. /**
  49976. * Define the image as a Monoscopic panoramic 360 image.
  49977. */
  49978. static readonly MODE_MONOSCOPIC: number;
  49979. /**
  49980. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49981. */
  49982. static readonly MODE_TOPBOTTOM: number;
  49983. /**
  49984. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49985. */
  49986. static readonly MODE_SIDEBYSIDE: number;
  49987. private _useDirectMapping;
  49988. /**
  49989. * The texture being displayed on the sphere
  49990. */
  49991. protected _photoTexture: Texture;
  49992. /**
  49993. * Gets or sets the texture being displayed on the sphere
  49994. */
  49995. get photoTexture(): Texture;
  49996. set photoTexture(value: Texture);
  49997. /**
  49998. * Observable raised when an error occured while loading the 360 image
  49999. */
  50000. onLoadErrorObservable: Observable<string>;
  50001. /**
  50002. * The skybox material
  50003. */
  50004. protected _material: BackgroundMaterial;
  50005. /**
  50006. * The surface used for the skybox
  50007. */
  50008. protected _mesh: Mesh;
  50009. /**
  50010. * Gets the mesh used for the skybox.
  50011. */
  50012. get mesh(): Mesh;
  50013. /**
  50014. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50015. * Also see the options.resolution property.
  50016. */
  50017. get fovMultiplier(): number;
  50018. set fovMultiplier(value: number);
  50019. private _imageMode;
  50020. /**
  50021. * Gets or set the current video mode for the video. It can be:
  50022. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50023. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50024. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50025. */
  50026. get imageMode(): number;
  50027. set imageMode(value: number);
  50028. /**
  50029. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50030. * @param name Element's name, child elements will append suffixes for their own names.
  50031. * @param urlsOfPhoto defines the url of the photo to display
  50032. * @param options defines an object containing optional or exposed sub element properties
  50033. * @param onError defines a callback called when an error occured while loading the texture
  50034. */
  50035. constructor(name: string, urlOfPhoto: string, options: {
  50036. resolution?: number;
  50037. size?: number;
  50038. useDirectMapping?: boolean;
  50039. faceForward?: boolean;
  50040. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50041. private _onBeforeCameraRenderObserver;
  50042. private _changeImageMode;
  50043. /**
  50044. * Releases resources associated with this node.
  50045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50047. */
  50048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * Class used to host RGBD texture specific utilities
  50054. */
  50055. export class RGBDTextureTools {
  50056. /**
  50057. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50058. * @param texture the texture to expand.
  50059. */
  50060. static ExpandRGBDTexture(texture: Texture): void;
  50061. }
  50062. }
  50063. declare module BABYLON {
  50064. /**
  50065. * Class used to host texture specific utilities
  50066. */
  50067. export class BRDFTextureTools {
  50068. /**
  50069. * Prevents texture cache collision
  50070. */
  50071. private static _instanceNumber;
  50072. /**
  50073. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50074. * @param scene defines the hosting scene
  50075. * @returns the environment BRDF texture
  50076. */
  50077. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50078. private static _environmentBRDFBase64Texture;
  50079. }
  50080. }
  50081. declare module BABYLON {
  50082. /**
  50083. * @hidden
  50084. */
  50085. export interface IMaterialClearCoatDefines {
  50086. CLEARCOAT: boolean;
  50087. CLEARCOAT_DEFAULTIOR: boolean;
  50088. CLEARCOAT_TEXTURE: boolean;
  50089. CLEARCOAT_TEXTUREDIRECTUV: number;
  50090. CLEARCOAT_BUMP: boolean;
  50091. CLEARCOAT_BUMPDIRECTUV: number;
  50092. CLEARCOAT_TINT: boolean;
  50093. CLEARCOAT_TINT_TEXTURE: boolean;
  50094. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50095. /** @hidden */
  50096. _areTexturesDirty: boolean;
  50097. }
  50098. /**
  50099. * Define the code related to the clear coat parameters of the pbr material.
  50100. */
  50101. export class PBRClearCoatConfiguration {
  50102. /**
  50103. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50104. * The default fits with a polyurethane material.
  50105. */
  50106. private static readonly _DefaultIndexOfRefraction;
  50107. private _isEnabled;
  50108. /**
  50109. * Defines if the clear coat is enabled in the material.
  50110. */
  50111. isEnabled: boolean;
  50112. /**
  50113. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50114. */
  50115. intensity: number;
  50116. /**
  50117. * Defines the clear coat layer roughness.
  50118. */
  50119. roughness: number;
  50120. private _indexOfRefraction;
  50121. /**
  50122. * Defines the index of refraction of the clear coat.
  50123. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50124. * The default fits with a polyurethane material.
  50125. * Changing the default value is more performance intensive.
  50126. */
  50127. indexOfRefraction: number;
  50128. private _texture;
  50129. /**
  50130. * Stores the clear coat values in a texture.
  50131. */
  50132. texture: Nullable<BaseTexture>;
  50133. private _bumpTexture;
  50134. /**
  50135. * Define the clear coat specific bump texture.
  50136. */
  50137. bumpTexture: Nullable<BaseTexture>;
  50138. private _isTintEnabled;
  50139. /**
  50140. * Defines if the clear coat tint is enabled in the material.
  50141. */
  50142. isTintEnabled: boolean;
  50143. /**
  50144. * Defines the clear coat tint of the material.
  50145. * This is only use if tint is enabled
  50146. */
  50147. tintColor: Color3;
  50148. /**
  50149. * Defines the distance at which the tint color should be found in the
  50150. * clear coat media.
  50151. * This is only use if tint is enabled
  50152. */
  50153. tintColorAtDistance: number;
  50154. /**
  50155. * Defines the clear coat layer thickness.
  50156. * This is only use if tint is enabled
  50157. */
  50158. tintThickness: number;
  50159. private _tintTexture;
  50160. /**
  50161. * Stores the clear tint values in a texture.
  50162. * rgb is tint
  50163. * a is a thickness factor
  50164. */
  50165. tintTexture: Nullable<BaseTexture>;
  50166. /** @hidden */
  50167. private _internalMarkAllSubMeshesAsTexturesDirty;
  50168. /** @hidden */
  50169. _markAllSubMeshesAsTexturesDirty(): void;
  50170. /**
  50171. * Instantiate a new istance of clear coat configuration.
  50172. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50173. */
  50174. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50175. /**
  50176. * Gets wehter the submesh is ready to be used or not.
  50177. * @param defines the list of "defines" to update.
  50178. * @param scene defines the scene the material belongs to.
  50179. * @param engine defines the engine the material belongs to.
  50180. * @param disableBumpMap defines wether the material disables bump or not.
  50181. * @returns - boolean indicating that the submesh is ready or not.
  50182. */
  50183. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50184. /**
  50185. * Checks to see if a texture is used in the material.
  50186. * @param defines the list of "defines" to update.
  50187. * @param scene defines the scene to the material belongs to.
  50188. */
  50189. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50190. /**
  50191. * Binds the material data.
  50192. * @param uniformBuffer defines the Uniform buffer to fill in.
  50193. * @param scene defines the scene the material belongs to.
  50194. * @param engine defines the engine the material belongs to.
  50195. * @param disableBumpMap defines wether the material disables bump or not.
  50196. * @param isFrozen defines wether the material is frozen or not.
  50197. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50198. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50199. */
  50200. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50201. /**
  50202. * Checks to see if a texture is used in the material.
  50203. * @param texture - Base texture to use.
  50204. * @returns - Boolean specifying if a texture is used in the material.
  50205. */
  50206. hasTexture(texture: BaseTexture): boolean;
  50207. /**
  50208. * Returns an array of the actively used textures.
  50209. * @param activeTextures Array of BaseTextures
  50210. */
  50211. getActiveTextures(activeTextures: BaseTexture[]): void;
  50212. /**
  50213. * Returns the animatable textures.
  50214. * @param animatables Array of animatable textures.
  50215. */
  50216. getAnimatables(animatables: IAnimatable[]): void;
  50217. /**
  50218. * Disposes the resources of the material.
  50219. * @param forceDisposeTextures - Forces the disposal of all textures.
  50220. */
  50221. dispose(forceDisposeTextures?: boolean): void;
  50222. /**
  50223. * Get the current class name of the texture useful for serialization or dynamic coding.
  50224. * @returns "PBRClearCoatConfiguration"
  50225. */
  50226. getClassName(): string;
  50227. /**
  50228. * Add fallbacks to the effect fallbacks list.
  50229. * @param defines defines the Base texture to use.
  50230. * @param fallbacks defines the current fallback list.
  50231. * @param currentRank defines the current fallback rank.
  50232. * @returns the new fallback rank.
  50233. */
  50234. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50235. /**
  50236. * Add the required uniforms to the current list.
  50237. * @param uniforms defines the current uniform list.
  50238. */
  50239. static AddUniforms(uniforms: string[]): void;
  50240. /**
  50241. * Add the required samplers to the current list.
  50242. * @param samplers defines the current sampler list.
  50243. */
  50244. static AddSamplers(samplers: string[]): void;
  50245. /**
  50246. * Add the required uniforms to the current buffer.
  50247. * @param uniformBuffer defines the current uniform buffer.
  50248. */
  50249. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50250. /**
  50251. * Makes a duplicate of the current configuration into another one.
  50252. * @param clearCoatConfiguration define the config where to copy the info
  50253. */
  50254. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50255. /**
  50256. * Serializes this clear coat configuration.
  50257. * @returns - An object with the serialized config.
  50258. */
  50259. serialize(): any;
  50260. /**
  50261. * Parses a anisotropy Configuration from a serialized object.
  50262. * @param source - Serialized object.
  50263. * @param scene Defines the scene we are parsing for
  50264. * @param rootUrl Defines the rootUrl to load from
  50265. */
  50266. parse(source: any, scene: Scene, rootUrl: string): void;
  50267. }
  50268. }
  50269. declare module BABYLON {
  50270. /**
  50271. * @hidden
  50272. */
  50273. export interface IMaterialAnisotropicDefines {
  50274. ANISOTROPIC: boolean;
  50275. ANISOTROPIC_TEXTURE: boolean;
  50276. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50277. MAINUV1: boolean;
  50278. _areTexturesDirty: boolean;
  50279. _needUVs: boolean;
  50280. }
  50281. /**
  50282. * Define the code related to the anisotropic parameters of the pbr material.
  50283. */
  50284. export class PBRAnisotropicConfiguration {
  50285. private _isEnabled;
  50286. /**
  50287. * Defines if the anisotropy is enabled in the material.
  50288. */
  50289. isEnabled: boolean;
  50290. /**
  50291. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50292. */
  50293. intensity: number;
  50294. /**
  50295. * Defines if the effect is along the tangents, bitangents or in between.
  50296. * By default, the effect is "strectching" the highlights along the tangents.
  50297. */
  50298. direction: Vector2;
  50299. private _texture;
  50300. /**
  50301. * Stores the anisotropy values in a texture.
  50302. * rg is direction (like normal from -1 to 1)
  50303. * b is a intensity
  50304. */
  50305. texture: Nullable<BaseTexture>;
  50306. /** @hidden */
  50307. private _internalMarkAllSubMeshesAsTexturesDirty;
  50308. /** @hidden */
  50309. _markAllSubMeshesAsTexturesDirty(): void;
  50310. /**
  50311. * Instantiate a new istance of anisotropy configuration.
  50312. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50313. */
  50314. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50315. /**
  50316. * Specifies that the submesh is ready to be used.
  50317. * @param defines the list of "defines" to update.
  50318. * @param scene defines the scene the material belongs to.
  50319. * @returns - boolean indicating that the submesh is ready or not.
  50320. */
  50321. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50322. /**
  50323. * Checks to see if a texture is used in the material.
  50324. * @param defines the list of "defines" to update.
  50325. * @param mesh the mesh we are preparing the defines for.
  50326. * @param scene defines the scene the material belongs to.
  50327. */
  50328. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50329. /**
  50330. * Binds the material data.
  50331. * @param uniformBuffer defines the Uniform buffer to fill in.
  50332. * @param scene defines the scene the material belongs to.
  50333. * @param isFrozen defines wether the material is frozen or not.
  50334. */
  50335. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50336. /**
  50337. * Checks to see if a texture is used in the material.
  50338. * @param texture - Base texture to use.
  50339. * @returns - Boolean specifying if a texture is used in the material.
  50340. */
  50341. hasTexture(texture: BaseTexture): boolean;
  50342. /**
  50343. * Returns an array of the actively used textures.
  50344. * @param activeTextures Array of BaseTextures
  50345. */
  50346. getActiveTextures(activeTextures: BaseTexture[]): void;
  50347. /**
  50348. * Returns the animatable textures.
  50349. * @param animatables Array of animatable textures.
  50350. */
  50351. getAnimatables(animatables: IAnimatable[]): void;
  50352. /**
  50353. * Disposes the resources of the material.
  50354. * @param forceDisposeTextures - Forces the disposal of all textures.
  50355. */
  50356. dispose(forceDisposeTextures?: boolean): void;
  50357. /**
  50358. * Get the current class name of the texture useful for serialization or dynamic coding.
  50359. * @returns "PBRAnisotropicConfiguration"
  50360. */
  50361. getClassName(): string;
  50362. /**
  50363. * Add fallbacks to the effect fallbacks list.
  50364. * @param defines defines the Base texture to use.
  50365. * @param fallbacks defines the current fallback list.
  50366. * @param currentRank defines the current fallback rank.
  50367. * @returns the new fallback rank.
  50368. */
  50369. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50370. /**
  50371. * Add the required uniforms to the current list.
  50372. * @param uniforms defines the current uniform list.
  50373. */
  50374. static AddUniforms(uniforms: string[]): void;
  50375. /**
  50376. * Add the required uniforms to the current buffer.
  50377. * @param uniformBuffer defines the current uniform buffer.
  50378. */
  50379. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50380. /**
  50381. * Add the required samplers to the current list.
  50382. * @param samplers defines the current sampler list.
  50383. */
  50384. static AddSamplers(samplers: string[]): void;
  50385. /**
  50386. * Makes a duplicate of the current configuration into another one.
  50387. * @param anisotropicConfiguration define the config where to copy the info
  50388. */
  50389. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50390. /**
  50391. * Serializes this anisotropy configuration.
  50392. * @returns - An object with the serialized config.
  50393. */
  50394. serialize(): any;
  50395. /**
  50396. * Parses a anisotropy Configuration from a serialized object.
  50397. * @param source - Serialized object.
  50398. * @param scene Defines the scene we are parsing for
  50399. * @param rootUrl Defines the rootUrl to load from
  50400. */
  50401. parse(source: any, scene: Scene, rootUrl: string): void;
  50402. }
  50403. }
  50404. declare module BABYLON {
  50405. /**
  50406. * @hidden
  50407. */
  50408. export interface IMaterialBRDFDefines {
  50409. BRDF_V_HEIGHT_CORRELATED: boolean;
  50410. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50411. SPHERICAL_HARMONICS: boolean;
  50412. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50413. /** @hidden */
  50414. _areMiscDirty: boolean;
  50415. }
  50416. /**
  50417. * Define the code related to the BRDF parameters of the pbr material.
  50418. */
  50419. export class PBRBRDFConfiguration {
  50420. /**
  50421. * Default value used for the energy conservation.
  50422. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50423. */
  50424. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50425. /**
  50426. * Default value used for the Smith Visibility Height Correlated mode.
  50427. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50428. */
  50429. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50430. /**
  50431. * Default value used for the IBL diffuse part.
  50432. * This can help switching back to the polynomials mode globally which is a tiny bit
  50433. * less GPU intensive at the drawback of a lower quality.
  50434. */
  50435. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50436. /**
  50437. * Default value used for activating energy conservation for the specular workflow.
  50438. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50439. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50440. */
  50441. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50442. private _useEnergyConservation;
  50443. /**
  50444. * Defines if the material uses energy conservation.
  50445. */
  50446. useEnergyConservation: boolean;
  50447. private _useSmithVisibilityHeightCorrelated;
  50448. /**
  50449. * LEGACY Mode set to false
  50450. * Defines if the material uses height smith correlated visibility term.
  50451. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50452. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50453. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50454. * Not relying on height correlated will also disable energy conservation.
  50455. */
  50456. useSmithVisibilityHeightCorrelated: boolean;
  50457. private _useSphericalHarmonics;
  50458. /**
  50459. * LEGACY Mode set to false
  50460. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50461. * diffuse part of the IBL.
  50462. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50463. * to the ground truth.
  50464. */
  50465. useSphericalHarmonics: boolean;
  50466. private _useSpecularGlossinessInputEnergyConservation;
  50467. /**
  50468. * Defines if the material uses energy conservation, when the specular workflow is active.
  50469. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50470. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50471. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50472. */
  50473. useSpecularGlossinessInputEnergyConservation: boolean;
  50474. /** @hidden */
  50475. private _internalMarkAllSubMeshesAsMiscDirty;
  50476. /** @hidden */
  50477. _markAllSubMeshesAsMiscDirty(): void;
  50478. /**
  50479. * Instantiate a new istance of clear coat configuration.
  50480. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50481. */
  50482. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50483. /**
  50484. * Checks to see if a texture is used in the material.
  50485. * @param defines the list of "defines" to update.
  50486. */
  50487. prepareDefines(defines: IMaterialBRDFDefines): void;
  50488. /**
  50489. * Get the current class name of the texture useful for serialization or dynamic coding.
  50490. * @returns "PBRClearCoatConfiguration"
  50491. */
  50492. getClassName(): string;
  50493. /**
  50494. * Makes a duplicate of the current configuration into another one.
  50495. * @param brdfConfiguration define the config where to copy the info
  50496. */
  50497. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50498. /**
  50499. * Serializes this BRDF configuration.
  50500. * @returns - An object with the serialized config.
  50501. */
  50502. serialize(): any;
  50503. /**
  50504. * Parses a anisotropy Configuration from a serialized object.
  50505. * @param source - Serialized object.
  50506. * @param scene Defines the scene we are parsing for
  50507. * @param rootUrl Defines the rootUrl to load from
  50508. */
  50509. parse(source: any, scene: Scene, rootUrl: string): void;
  50510. }
  50511. }
  50512. declare module BABYLON {
  50513. /**
  50514. * @hidden
  50515. */
  50516. export interface IMaterialSheenDefines {
  50517. SHEEN: boolean;
  50518. SHEEN_TEXTURE: boolean;
  50519. SHEEN_TEXTUREDIRECTUV: number;
  50520. SHEEN_LINKWITHALBEDO: boolean;
  50521. SHEEN_ROUGHNESS: boolean;
  50522. SHEEN_ALBEDOSCALING: boolean;
  50523. /** @hidden */
  50524. _areTexturesDirty: boolean;
  50525. }
  50526. /**
  50527. * Define the code related to the Sheen parameters of the pbr material.
  50528. */
  50529. export class PBRSheenConfiguration {
  50530. private _isEnabled;
  50531. /**
  50532. * Defines if the material uses sheen.
  50533. */
  50534. isEnabled: boolean;
  50535. private _linkSheenWithAlbedo;
  50536. /**
  50537. * Defines if the sheen is linked to the sheen color.
  50538. */
  50539. linkSheenWithAlbedo: boolean;
  50540. /**
  50541. * Defines the sheen intensity.
  50542. */
  50543. intensity: number;
  50544. /**
  50545. * Defines the sheen color.
  50546. */
  50547. color: Color3;
  50548. private _texture;
  50549. /**
  50550. * Stores the sheen tint values in a texture.
  50551. * rgb is tint
  50552. * a is a intensity
  50553. */
  50554. texture: Nullable<BaseTexture>;
  50555. private _roughness;
  50556. /**
  50557. * Defines the sheen roughness.
  50558. * It is not taken into account if linkSheenWithAlbedo is true.
  50559. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50560. */
  50561. roughness: Nullable<number>;
  50562. private _albedoScaling;
  50563. /**
  50564. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50565. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50566. * making it easier to setup and tweak the effect
  50567. */
  50568. albedoScaling: boolean;
  50569. /** @hidden */
  50570. private _internalMarkAllSubMeshesAsTexturesDirty;
  50571. /** @hidden */
  50572. _markAllSubMeshesAsTexturesDirty(): void;
  50573. /**
  50574. * Instantiate a new istance of clear coat configuration.
  50575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50576. */
  50577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50578. /**
  50579. * Specifies that the submesh is ready to be used.
  50580. * @param defines the list of "defines" to update.
  50581. * @param scene defines the scene the material belongs to.
  50582. * @returns - boolean indicating that the submesh is ready or not.
  50583. */
  50584. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50585. /**
  50586. * Checks to see if a texture is used in the material.
  50587. * @param defines the list of "defines" to update.
  50588. * @param scene defines the scene the material belongs to.
  50589. */
  50590. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50591. /**
  50592. * Binds the material data.
  50593. * @param uniformBuffer defines the Uniform buffer to fill in.
  50594. * @param scene defines the scene the material belongs to.
  50595. * @param isFrozen defines wether the material is frozen or not.
  50596. */
  50597. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50598. /**
  50599. * Checks to see if a texture is used in the material.
  50600. * @param texture - Base texture to use.
  50601. * @returns - Boolean specifying if a texture is used in the material.
  50602. */
  50603. hasTexture(texture: BaseTexture): boolean;
  50604. /**
  50605. * Returns an array of the actively used textures.
  50606. * @param activeTextures Array of BaseTextures
  50607. */
  50608. getActiveTextures(activeTextures: BaseTexture[]): void;
  50609. /**
  50610. * Returns the animatable textures.
  50611. * @param animatables Array of animatable textures.
  50612. */
  50613. getAnimatables(animatables: IAnimatable[]): void;
  50614. /**
  50615. * Disposes the resources of the material.
  50616. * @param forceDisposeTextures - Forces the disposal of all textures.
  50617. */
  50618. dispose(forceDisposeTextures?: boolean): void;
  50619. /**
  50620. * Get the current class name of the texture useful for serialization or dynamic coding.
  50621. * @returns "PBRSheenConfiguration"
  50622. */
  50623. getClassName(): string;
  50624. /**
  50625. * Add fallbacks to the effect fallbacks list.
  50626. * @param defines defines the Base texture to use.
  50627. * @param fallbacks defines the current fallback list.
  50628. * @param currentRank defines the current fallback rank.
  50629. * @returns the new fallback rank.
  50630. */
  50631. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50632. /**
  50633. * Add the required uniforms to the current list.
  50634. * @param uniforms defines the current uniform list.
  50635. */
  50636. static AddUniforms(uniforms: string[]): void;
  50637. /**
  50638. * Add the required uniforms to the current buffer.
  50639. * @param uniformBuffer defines the current uniform buffer.
  50640. */
  50641. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50642. /**
  50643. * Add the required samplers to the current list.
  50644. * @param samplers defines the current sampler list.
  50645. */
  50646. static AddSamplers(samplers: string[]): void;
  50647. /**
  50648. * Makes a duplicate of the current configuration into another one.
  50649. * @param sheenConfiguration define the config where to copy the info
  50650. */
  50651. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50652. /**
  50653. * Serializes this BRDF configuration.
  50654. * @returns - An object with the serialized config.
  50655. */
  50656. serialize(): any;
  50657. /**
  50658. * Parses a anisotropy Configuration from a serialized object.
  50659. * @param source - Serialized object.
  50660. * @param scene Defines the scene we are parsing for
  50661. * @param rootUrl Defines the rootUrl to load from
  50662. */
  50663. parse(source: any, scene: Scene, rootUrl: string): void;
  50664. }
  50665. }
  50666. declare module BABYLON {
  50667. /**
  50668. * @hidden
  50669. */
  50670. export interface IMaterialSubSurfaceDefines {
  50671. SUBSURFACE: boolean;
  50672. SS_REFRACTION: boolean;
  50673. SS_TRANSLUCENCY: boolean;
  50674. SS_SCATERRING: boolean;
  50675. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50676. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50677. SS_REFRACTIONMAP_3D: boolean;
  50678. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50679. SS_LODINREFRACTIONALPHA: boolean;
  50680. SS_GAMMAREFRACTION: boolean;
  50681. SS_RGBDREFRACTION: boolean;
  50682. SS_LINEARSPECULARREFRACTION: boolean;
  50683. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50684. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50685. /** @hidden */
  50686. _areTexturesDirty: boolean;
  50687. }
  50688. /**
  50689. * Define the code related to the sub surface parameters of the pbr material.
  50690. */
  50691. export class PBRSubSurfaceConfiguration {
  50692. private _isRefractionEnabled;
  50693. /**
  50694. * Defines if the refraction is enabled in the material.
  50695. */
  50696. isRefractionEnabled: boolean;
  50697. private _isTranslucencyEnabled;
  50698. /**
  50699. * Defines if the translucency is enabled in the material.
  50700. */
  50701. isTranslucencyEnabled: boolean;
  50702. private _isScatteringEnabled;
  50703. /**
  50704. * Defines the refraction intensity of the material.
  50705. * The refraction when enabled replaces the Diffuse part of the material.
  50706. * The intensity helps transitionning between diffuse and refraction.
  50707. */
  50708. refractionIntensity: number;
  50709. /**
  50710. * Defines the translucency intensity of the material.
  50711. * When translucency has been enabled, this defines how much of the "translucency"
  50712. * is addded to the diffuse part of the material.
  50713. */
  50714. translucencyIntensity: number;
  50715. /**
  50716. * Defines the scattering intensity of the material.
  50717. * When scattering has been enabled, this defines how much of the "scattered light"
  50718. * is addded to the diffuse part of the material.
  50719. */
  50720. scatteringIntensity: number;
  50721. private _thicknessTexture;
  50722. /**
  50723. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50724. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50725. * 0 would mean minimumThickness
  50726. * 1 would mean maximumThickness
  50727. * The other channels might be use as a mask to vary the different effects intensity.
  50728. */
  50729. thicknessTexture: Nullable<BaseTexture>;
  50730. private _refractionTexture;
  50731. /**
  50732. * Defines the texture to use for refraction.
  50733. */
  50734. refractionTexture: Nullable<BaseTexture>;
  50735. private _indexOfRefraction;
  50736. /**
  50737. * Defines the index of refraction used in the material.
  50738. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50739. */
  50740. indexOfRefraction: number;
  50741. private _invertRefractionY;
  50742. /**
  50743. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50744. */
  50745. invertRefractionY: boolean;
  50746. private _linkRefractionWithTransparency;
  50747. /**
  50748. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50749. * Materials half opaque for instance using refraction could benefit from this control.
  50750. */
  50751. linkRefractionWithTransparency: boolean;
  50752. /**
  50753. * Defines the minimum thickness stored in the thickness map.
  50754. * If no thickness map is defined, this value will be used to simulate thickness.
  50755. */
  50756. minimumThickness: number;
  50757. /**
  50758. * Defines the maximum thickness stored in the thickness map.
  50759. */
  50760. maximumThickness: number;
  50761. /**
  50762. * Defines the volume tint of the material.
  50763. * This is used for both translucency and scattering.
  50764. */
  50765. tintColor: Color3;
  50766. /**
  50767. * Defines the distance at which the tint color should be found in the media.
  50768. * This is used for refraction only.
  50769. */
  50770. tintColorAtDistance: number;
  50771. /**
  50772. * Defines how far each channel transmit through the media.
  50773. * It is defined as a color to simplify it selection.
  50774. */
  50775. diffusionDistance: Color3;
  50776. private _useMaskFromThicknessTexture;
  50777. /**
  50778. * Stores the intensity of the different subsurface effects in the thickness texture.
  50779. * * the green channel is the translucency intensity.
  50780. * * the blue channel is the scattering intensity.
  50781. * * the alpha channel is the refraction intensity.
  50782. */
  50783. useMaskFromThicknessTexture: boolean;
  50784. /** @hidden */
  50785. private _internalMarkAllSubMeshesAsTexturesDirty;
  50786. /** @hidden */
  50787. _markAllSubMeshesAsTexturesDirty(): void;
  50788. /**
  50789. * Instantiate a new istance of sub surface configuration.
  50790. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50791. */
  50792. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50793. /**
  50794. * Gets wehter the submesh is ready to be used or not.
  50795. * @param defines the list of "defines" to update.
  50796. * @param scene defines the scene the material belongs to.
  50797. * @returns - boolean indicating that the submesh is ready or not.
  50798. */
  50799. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50800. /**
  50801. * Checks to see if a texture is used in the material.
  50802. * @param defines the list of "defines" to update.
  50803. * @param scene defines the scene to the material belongs to.
  50804. */
  50805. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50806. /**
  50807. * Binds the material data.
  50808. * @param uniformBuffer defines the Uniform buffer to fill in.
  50809. * @param scene defines the scene the material belongs to.
  50810. * @param engine defines the engine the material belongs to.
  50811. * @param isFrozen defines wether the material is frozen or not.
  50812. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50813. */
  50814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50815. /**
  50816. * Unbinds the material from the mesh.
  50817. * @param activeEffect defines the effect that should be unbound from.
  50818. * @returns true if unbound, otherwise false
  50819. */
  50820. unbind(activeEffect: Effect): boolean;
  50821. /**
  50822. * Returns the texture used for refraction or null if none is used.
  50823. * @param scene defines the scene the material belongs to.
  50824. * @returns - Refraction texture if present. If no refraction texture and refraction
  50825. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50826. */
  50827. private _getRefractionTexture;
  50828. /**
  50829. * Returns true if alpha blending should be disabled.
  50830. */
  50831. get disableAlphaBlending(): boolean;
  50832. /**
  50833. * Fills the list of render target textures.
  50834. * @param renderTargets the list of render targets to update
  50835. */
  50836. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50837. /**
  50838. * Checks to see if a texture is used in the material.
  50839. * @param texture - Base texture to use.
  50840. * @returns - Boolean specifying if a texture is used in the material.
  50841. */
  50842. hasTexture(texture: BaseTexture): boolean;
  50843. /**
  50844. * Gets a boolean indicating that current material needs to register RTT
  50845. * @returns true if this uses a render target otherwise false.
  50846. */
  50847. hasRenderTargetTextures(): boolean;
  50848. /**
  50849. * Returns an array of the actively used textures.
  50850. * @param activeTextures Array of BaseTextures
  50851. */
  50852. getActiveTextures(activeTextures: BaseTexture[]): void;
  50853. /**
  50854. * Returns the animatable textures.
  50855. * @param animatables Array of animatable textures.
  50856. */
  50857. getAnimatables(animatables: IAnimatable[]): void;
  50858. /**
  50859. * Disposes the resources of the material.
  50860. * @param forceDisposeTextures - Forces the disposal of all textures.
  50861. */
  50862. dispose(forceDisposeTextures?: boolean): void;
  50863. /**
  50864. * Get the current class name of the texture useful for serialization or dynamic coding.
  50865. * @returns "PBRSubSurfaceConfiguration"
  50866. */
  50867. getClassName(): string;
  50868. /**
  50869. * Add fallbacks to the effect fallbacks list.
  50870. * @param defines defines the Base texture to use.
  50871. * @param fallbacks defines the current fallback list.
  50872. * @param currentRank defines the current fallback rank.
  50873. * @returns the new fallback rank.
  50874. */
  50875. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50876. /**
  50877. * Add the required uniforms to the current list.
  50878. * @param uniforms defines the current uniform list.
  50879. */
  50880. static AddUniforms(uniforms: string[]): void;
  50881. /**
  50882. * Add the required samplers to the current list.
  50883. * @param samplers defines the current sampler list.
  50884. */
  50885. static AddSamplers(samplers: string[]): void;
  50886. /**
  50887. * Add the required uniforms to the current buffer.
  50888. * @param uniformBuffer defines the current uniform buffer.
  50889. */
  50890. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50891. /**
  50892. * Makes a duplicate of the current configuration into another one.
  50893. * @param configuration define the config where to copy the info
  50894. */
  50895. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50896. /**
  50897. * Serializes this Sub Surface configuration.
  50898. * @returns - An object with the serialized config.
  50899. */
  50900. serialize(): any;
  50901. /**
  50902. * Parses a anisotropy Configuration from a serialized object.
  50903. * @param source - Serialized object.
  50904. * @param scene Defines the scene we are parsing for
  50905. * @param rootUrl Defines the rootUrl to load from
  50906. */
  50907. parse(source: any, scene: Scene, rootUrl: string): void;
  50908. }
  50909. }
  50910. declare module BABYLON {
  50911. /** @hidden */
  50912. export var pbrFragmentDeclaration: {
  50913. name: string;
  50914. shader: string;
  50915. };
  50916. }
  50917. declare module BABYLON {
  50918. /** @hidden */
  50919. export var pbrUboDeclaration: {
  50920. name: string;
  50921. shader: string;
  50922. };
  50923. }
  50924. declare module BABYLON {
  50925. /** @hidden */
  50926. export var pbrFragmentExtraDeclaration: {
  50927. name: string;
  50928. shader: string;
  50929. };
  50930. }
  50931. declare module BABYLON {
  50932. /** @hidden */
  50933. export var pbrFragmentSamplersDeclaration: {
  50934. name: string;
  50935. shader: string;
  50936. };
  50937. }
  50938. declare module BABYLON {
  50939. /** @hidden */
  50940. export var pbrHelperFunctions: {
  50941. name: string;
  50942. shader: string;
  50943. };
  50944. }
  50945. declare module BABYLON {
  50946. /** @hidden */
  50947. export var harmonicsFunctions: {
  50948. name: string;
  50949. shader: string;
  50950. };
  50951. }
  50952. declare module BABYLON {
  50953. /** @hidden */
  50954. export var pbrDirectLightingSetupFunctions: {
  50955. name: string;
  50956. shader: string;
  50957. };
  50958. }
  50959. declare module BABYLON {
  50960. /** @hidden */
  50961. export var pbrDirectLightingFalloffFunctions: {
  50962. name: string;
  50963. shader: string;
  50964. };
  50965. }
  50966. declare module BABYLON {
  50967. /** @hidden */
  50968. export var pbrBRDFFunctions: {
  50969. name: string;
  50970. shader: string;
  50971. };
  50972. }
  50973. declare module BABYLON {
  50974. /** @hidden */
  50975. export var pbrDirectLightingFunctions: {
  50976. name: string;
  50977. shader: string;
  50978. };
  50979. }
  50980. declare module BABYLON {
  50981. /** @hidden */
  50982. export var pbrIBLFunctions: {
  50983. name: string;
  50984. shader: string;
  50985. };
  50986. }
  50987. declare module BABYLON {
  50988. /** @hidden */
  50989. export var pbrDebug: {
  50990. name: string;
  50991. shader: string;
  50992. };
  50993. }
  50994. declare module BABYLON {
  50995. /** @hidden */
  50996. export var pbrPixelShader: {
  50997. name: string;
  50998. shader: string;
  50999. };
  51000. }
  51001. declare module BABYLON {
  51002. /** @hidden */
  51003. export var pbrVertexDeclaration: {
  51004. name: string;
  51005. shader: string;
  51006. };
  51007. }
  51008. declare module BABYLON {
  51009. /** @hidden */
  51010. export var pbrVertexShader: {
  51011. name: string;
  51012. shader: string;
  51013. };
  51014. }
  51015. declare module BABYLON {
  51016. /**
  51017. * Manages the defines for the PBR Material.
  51018. * @hidden
  51019. */
  51020. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51021. PBR: boolean;
  51022. MAINUV1: boolean;
  51023. MAINUV2: boolean;
  51024. UV1: boolean;
  51025. UV2: boolean;
  51026. ALBEDO: boolean;
  51027. GAMMAALBEDO: boolean;
  51028. ALBEDODIRECTUV: number;
  51029. VERTEXCOLOR: boolean;
  51030. AMBIENT: boolean;
  51031. AMBIENTDIRECTUV: number;
  51032. AMBIENTINGRAYSCALE: boolean;
  51033. OPACITY: boolean;
  51034. VERTEXALPHA: boolean;
  51035. OPACITYDIRECTUV: number;
  51036. OPACITYRGB: boolean;
  51037. ALPHATEST: boolean;
  51038. DEPTHPREPASS: boolean;
  51039. ALPHABLEND: boolean;
  51040. ALPHAFROMALBEDO: boolean;
  51041. ALPHATESTVALUE: string;
  51042. SPECULAROVERALPHA: boolean;
  51043. RADIANCEOVERALPHA: boolean;
  51044. ALPHAFRESNEL: boolean;
  51045. LINEARALPHAFRESNEL: boolean;
  51046. PREMULTIPLYALPHA: boolean;
  51047. EMISSIVE: boolean;
  51048. EMISSIVEDIRECTUV: number;
  51049. REFLECTIVITY: boolean;
  51050. REFLECTIVITYDIRECTUV: number;
  51051. SPECULARTERM: boolean;
  51052. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51053. MICROSURFACEAUTOMATIC: boolean;
  51054. LODBASEDMICROSFURACE: boolean;
  51055. MICROSURFACEMAP: boolean;
  51056. MICROSURFACEMAPDIRECTUV: number;
  51057. METALLICWORKFLOW: boolean;
  51058. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51059. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51060. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51061. AOSTOREINMETALMAPRED: boolean;
  51062. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51063. ENVIRONMENTBRDF: boolean;
  51064. ENVIRONMENTBRDF_RGBD: boolean;
  51065. NORMAL: boolean;
  51066. TANGENT: boolean;
  51067. BUMP: boolean;
  51068. BUMPDIRECTUV: number;
  51069. OBJECTSPACE_NORMALMAP: boolean;
  51070. PARALLAX: boolean;
  51071. PARALLAXOCCLUSION: boolean;
  51072. NORMALXYSCALE: boolean;
  51073. LIGHTMAP: boolean;
  51074. LIGHTMAPDIRECTUV: number;
  51075. USELIGHTMAPASSHADOWMAP: boolean;
  51076. GAMMALIGHTMAP: boolean;
  51077. RGBDLIGHTMAP: boolean;
  51078. REFLECTION: boolean;
  51079. REFLECTIONMAP_3D: boolean;
  51080. REFLECTIONMAP_SPHERICAL: boolean;
  51081. REFLECTIONMAP_PLANAR: boolean;
  51082. REFLECTIONMAP_CUBIC: boolean;
  51083. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51084. REFLECTIONMAP_PROJECTION: boolean;
  51085. REFLECTIONMAP_SKYBOX: boolean;
  51086. REFLECTIONMAP_EXPLICIT: boolean;
  51087. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51088. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51089. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51090. INVERTCUBICMAP: boolean;
  51091. USESPHERICALFROMREFLECTIONMAP: boolean;
  51092. USEIRRADIANCEMAP: boolean;
  51093. SPHERICAL_HARMONICS: boolean;
  51094. USESPHERICALINVERTEX: boolean;
  51095. REFLECTIONMAP_OPPOSITEZ: boolean;
  51096. LODINREFLECTIONALPHA: boolean;
  51097. GAMMAREFLECTION: boolean;
  51098. RGBDREFLECTION: boolean;
  51099. LINEARSPECULARREFLECTION: boolean;
  51100. RADIANCEOCCLUSION: boolean;
  51101. HORIZONOCCLUSION: boolean;
  51102. INSTANCES: boolean;
  51103. NUM_BONE_INFLUENCERS: number;
  51104. BonesPerMesh: number;
  51105. BONETEXTURE: boolean;
  51106. NONUNIFORMSCALING: boolean;
  51107. MORPHTARGETS: boolean;
  51108. MORPHTARGETS_NORMAL: boolean;
  51109. MORPHTARGETS_TANGENT: boolean;
  51110. MORPHTARGETS_UV: boolean;
  51111. NUM_MORPH_INFLUENCERS: number;
  51112. IMAGEPROCESSING: boolean;
  51113. VIGNETTE: boolean;
  51114. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51115. VIGNETTEBLENDMODEOPAQUE: boolean;
  51116. TONEMAPPING: boolean;
  51117. TONEMAPPING_ACES: boolean;
  51118. CONTRAST: boolean;
  51119. COLORCURVES: boolean;
  51120. COLORGRADING: boolean;
  51121. COLORGRADING3D: boolean;
  51122. SAMPLER3DGREENDEPTH: boolean;
  51123. SAMPLER3DBGRMAP: boolean;
  51124. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51125. EXPOSURE: boolean;
  51126. MULTIVIEW: boolean;
  51127. USEPHYSICALLIGHTFALLOFF: boolean;
  51128. USEGLTFLIGHTFALLOFF: boolean;
  51129. TWOSIDEDLIGHTING: boolean;
  51130. SHADOWFLOAT: boolean;
  51131. CLIPPLANE: boolean;
  51132. CLIPPLANE2: boolean;
  51133. CLIPPLANE3: boolean;
  51134. CLIPPLANE4: boolean;
  51135. CLIPPLANE5: boolean;
  51136. CLIPPLANE6: boolean;
  51137. POINTSIZE: boolean;
  51138. FOG: boolean;
  51139. LOGARITHMICDEPTH: boolean;
  51140. FORCENORMALFORWARD: boolean;
  51141. SPECULARAA: boolean;
  51142. CLEARCOAT: boolean;
  51143. CLEARCOAT_DEFAULTIOR: boolean;
  51144. CLEARCOAT_TEXTURE: boolean;
  51145. CLEARCOAT_TEXTUREDIRECTUV: number;
  51146. CLEARCOAT_BUMP: boolean;
  51147. CLEARCOAT_BUMPDIRECTUV: number;
  51148. CLEARCOAT_TINT: boolean;
  51149. CLEARCOAT_TINT_TEXTURE: boolean;
  51150. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51151. ANISOTROPIC: boolean;
  51152. ANISOTROPIC_TEXTURE: boolean;
  51153. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51154. BRDF_V_HEIGHT_CORRELATED: boolean;
  51155. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51156. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51157. SHEEN: boolean;
  51158. SHEEN_TEXTURE: boolean;
  51159. SHEEN_TEXTUREDIRECTUV: number;
  51160. SHEEN_LINKWITHALBEDO: boolean;
  51161. SHEEN_ROUGHNESS: boolean;
  51162. SHEEN_ALBEDOSCALING: boolean;
  51163. SUBSURFACE: boolean;
  51164. SS_REFRACTION: boolean;
  51165. SS_TRANSLUCENCY: boolean;
  51166. SS_SCATERRING: boolean;
  51167. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51168. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51169. SS_REFRACTIONMAP_3D: boolean;
  51170. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51171. SS_LODINREFRACTIONALPHA: boolean;
  51172. SS_GAMMAREFRACTION: boolean;
  51173. SS_RGBDREFRACTION: boolean;
  51174. SS_LINEARSPECULARREFRACTION: boolean;
  51175. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51176. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51177. UNLIT: boolean;
  51178. DEBUGMODE: number;
  51179. /**
  51180. * Initializes the PBR Material defines.
  51181. */
  51182. constructor();
  51183. /**
  51184. * Resets the PBR Material defines.
  51185. */
  51186. reset(): void;
  51187. }
  51188. /**
  51189. * The Physically based material base class of BJS.
  51190. *
  51191. * This offers the main features of a standard PBR material.
  51192. * For more information, please refer to the documentation :
  51193. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51194. */
  51195. export abstract class PBRBaseMaterial extends PushMaterial {
  51196. /**
  51197. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51198. */
  51199. static readonly PBRMATERIAL_OPAQUE: number;
  51200. /**
  51201. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51202. */
  51203. static readonly PBRMATERIAL_ALPHATEST: number;
  51204. /**
  51205. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51206. */
  51207. static readonly PBRMATERIAL_ALPHABLEND: number;
  51208. /**
  51209. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51210. * They are also discarded below the alpha cutoff threshold to improve performances.
  51211. */
  51212. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51213. /**
  51214. * Defines the default value of how much AO map is occluding the analytical lights
  51215. * (point spot...).
  51216. */
  51217. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51218. /**
  51219. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51220. */
  51221. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51222. /**
  51223. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51224. * to enhance interoperability with other engines.
  51225. */
  51226. static readonly LIGHTFALLOFF_GLTF: number;
  51227. /**
  51228. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51229. * to enhance interoperability with other materials.
  51230. */
  51231. static readonly LIGHTFALLOFF_STANDARD: number;
  51232. /**
  51233. * Intensity of the direct lights e.g. the four lights available in your scene.
  51234. * This impacts both the direct diffuse and specular highlights.
  51235. */
  51236. protected _directIntensity: number;
  51237. /**
  51238. * Intensity of the emissive part of the material.
  51239. * This helps controlling the emissive effect without modifying the emissive color.
  51240. */
  51241. protected _emissiveIntensity: number;
  51242. /**
  51243. * Intensity of the environment e.g. how much the environment will light the object
  51244. * either through harmonics for rough material or through the refelction for shiny ones.
  51245. */
  51246. protected _environmentIntensity: number;
  51247. /**
  51248. * This is a special control allowing the reduction of the specular highlights coming from the
  51249. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51250. */
  51251. protected _specularIntensity: number;
  51252. /**
  51253. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51254. */
  51255. private _lightingInfos;
  51256. /**
  51257. * Debug Control allowing disabling the bump map on this material.
  51258. */
  51259. protected _disableBumpMap: boolean;
  51260. /**
  51261. * AKA Diffuse Texture in standard nomenclature.
  51262. */
  51263. protected _albedoTexture: Nullable<BaseTexture>;
  51264. /**
  51265. * AKA Occlusion Texture in other nomenclature.
  51266. */
  51267. protected _ambientTexture: Nullable<BaseTexture>;
  51268. /**
  51269. * AKA Occlusion Texture Intensity in other nomenclature.
  51270. */
  51271. protected _ambientTextureStrength: number;
  51272. /**
  51273. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51274. * 1 means it completely occludes it
  51275. * 0 mean it has no impact
  51276. */
  51277. protected _ambientTextureImpactOnAnalyticalLights: number;
  51278. /**
  51279. * Stores the alpha values in a texture.
  51280. */
  51281. protected _opacityTexture: Nullable<BaseTexture>;
  51282. /**
  51283. * Stores the reflection values in a texture.
  51284. */
  51285. protected _reflectionTexture: Nullable<BaseTexture>;
  51286. /**
  51287. * Stores the emissive values in a texture.
  51288. */
  51289. protected _emissiveTexture: Nullable<BaseTexture>;
  51290. /**
  51291. * AKA Specular texture in other nomenclature.
  51292. */
  51293. protected _reflectivityTexture: Nullable<BaseTexture>;
  51294. /**
  51295. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51296. */
  51297. protected _metallicTexture: Nullable<BaseTexture>;
  51298. /**
  51299. * Specifies the metallic scalar of the metallic/roughness workflow.
  51300. * Can also be used to scale the metalness values of the metallic texture.
  51301. */
  51302. protected _metallic: Nullable<number>;
  51303. /**
  51304. * Specifies the roughness scalar of the metallic/roughness workflow.
  51305. * Can also be used to scale the roughness values of the metallic texture.
  51306. */
  51307. protected _roughness: Nullable<number>;
  51308. /**
  51309. * Specifies the an F0 factor to help configuring the material F0.
  51310. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51311. * to 0.5 the previously hard coded value stays the same.
  51312. * Can also be used to scale the F0 values of the metallic texture.
  51313. */
  51314. protected _metallicF0Factor: number;
  51315. /**
  51316. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51317. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51318. * your expectation as it multiplies with the texture data.
  51319. */
  51320. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51321. /**
  51322. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51323. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51324. */
  51325. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51326. /**
  51327. * Stores surface normal data used to displace a mesh in a texture.
  51328. */
  51329. protected _bumpTexture: Nullable<BaseTexture>;
  51330. /**
  51331. * Stores the pre-calculated light information of a mesh in a texture.
  51332. */
  51333. protected _lightmapTexture: Nullable<BaseTexture>;
  51334. /**
  51335. * The color of a material in ambient lighting.
  51336. */
  51337. protected _ambientColor: Color3;
  51338. /**
  51339. * AKA Diffuse Color in other nomenclature.
  51340. */
  51341. protected _albedoColor: Color3;
  51342. /**
  51343. * AKA Specular Color in other nomenclature.
  51344. */
  51345. protected _reflectivityColor: Color3;
  51346. /**
  51347. * The color applied when light is reflected from a material.
  51348. */
  51349. protected _reflectionColor: Color3;
  51350. /**
  51351. * The color applied when light is emitted from a material.
  51352. */
  51353. protected _emissiveColor: Color3;
  51354. /**
  51355. * AKA Glossiness in other nomenclature.
  51356. */
  51357. protected _microSurface: number;
  51358. /**
  51359. * Specifies that the material will use the light map as a show map.
  51360. */
  51361. protected _useLightmapAsShadowmap: boolean;
  51362. /**
  51363. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51364. * makes the reflect vector face the model (under horizon).
  51365. */
  51366. protected _useHorizonOcclusion: boolean;
  51367. /**
  51368. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51369. * too much the area relying on ambient texture to define their ambient occlusion.
  51370. */
  51371. protected _useRadianceOcclusion: boolean;
  51372. /**
  51373. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51374. */
  51375. protected _useAlphaFromAlbedoTexture: boolean;
  51376. /**
  51377. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51378. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51379. */
  51380. protected _useSpecularOverAlpha: boolean;
  51381. /**
  51382. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51383. */
  51384. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51385. /**
  51386. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51387. */
  51388. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51389. /**
  51390. * Specifies if the metallic texture contains the roughness information in its green channel.
  51391. */
  51392. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51393. /**
  51394. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51395. */
  51396. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51397. /**
  51398. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51399. */
  51400. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51401. /**
  51402. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51403. */
  51404. protected _useAmbientInGrayScale: boolean;
  51405. /**
  51406. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51407. * The material will try to infer what glossiness each pixel should be.
  51408. */
  51409. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51410. /**
  51411. * Defines the falloff type used in this material.
  51412. * It by default is Physical.
  51413. */
  51414. protected _lightFalloff: number;
  51415. /**
  51416. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51417. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51418. */
  51419. protected _useRadianceOverAlpha: boolean;
  51420. /**
  51421. * Allows using an object space normal map (instead of tangent space).
  51422. */
  51423. protected _useObjectSpaceNormalMap: boolean;
  51424. /**
  51425. * Allows using the bump map in parallax mode.
  51426. */
  51427. protected _useParallax: boolean;
  51428. /**
  51429. * Allows using the bump map in parallax occlusion mode.
  51430. */
  51431. protected _useParallaxOcclusion: boolean;
  51432. /**
  51433. * Controls the scale bias of the parallax mode.
  51434. */
  51435. protected _parallaxScaleBias: number;
  51436. /**
  51437. * If sets to true, disables all the lights affecting the material.
  51438. */
  51439. protected _disableLighting: boolean;
  51440. /**
  51441. * Number of Simultaneous lights allowed on the material.
  51442. */
  51443. protected _maxSimultaneousLights: number;
  51444. /**
  51445. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51446. */
  51447. protected _invertNormalMapX: boolean;
  51448. /**
  51449. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51450. */
  51451. protected _invertNormalMapY: boolean;
  51452. /**
  51453. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51454. */
  51455. protected _twoSidedLighting: boolean;
  51456. /**
  51457. * Defines the alpha limits in alpha test mode.
  51458. */
  51459. protected _alphaCutOff: number;
  51460. /**
  51461. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51462. */
  51463. protected _forceAlphaTest: boolean;
  51464. /**
  51465. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51466. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51467. */
  51468. protected _useAlphaFresnel: boolean;
  51469. /**
  51470. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51471. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51472. */
  51473. protected _useLinearAlphaFresnel: boolean;
  51474. /**
  51475. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51476. * from cos thetav and roughness:
  51477. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51478. */
  51479. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51480. /**
  51481. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51482. */
  51483. protected _forceIrradianceInFragment: boolean;
  51484. /**
  51485. * Force normal to face away from face.
  51486. */
  51487. protected _forceNormalForward: boolean;
  51488. /**
  51489. * Enables specular anti aliasing in the PBR shader.
  51490. * It will both interacts on the Geometry for analytical and IBL lighting.
  51491. * It also prefilter the roughness map based on the bump values.
  51492. */
  51493. protected _enableSpecularAntiAliasing: boolean;
  51494. /**
  51495. * Default configuration related to image processing available in the PBR Material.
  51496. */
  51497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51498. /**
  51499. * Keep track of the image processing observer to allow dispose and replace.
  51500. */
  51501. private _imageProcessingObserver;
  51502. /**
  51503. * Attaches a new image processing configuration to the PBR Material.
  51504. * @param configuration
  51505. */
  51506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51507. /**
  51508. * Stores the available render targets.
  51509. */
  51510. private _renderTargets;
  51511. /**
  51512. * Sets the global ambient color for the material used in lighting calculations.
  51513. */
  51514. private _globalAmbientColor;
  51515. /**
  51516. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51517. */
  51518. private _useLogarithmicDepth;
  51519. /**
  51520. * If set to true, no lighting calculations will be applied.
  51521. */
  51522. private _unlit;
  51523. private _debugMode;
  51524. /**
  51525. * @hidden
  51526. * This is reserved for the inspector.
  51527. * Defines the material debug mode.
  51528. * It helps seeing only some components of the material while troubleshooting.
  51529. */
  51530. debugMode: number;
  51531. /**
  51532. * @hidden
  51533. * This is reserved for the inspector.
  51534. * Specify from where on screen the debug mode should start.
  51535. * The value goes from -1 (full screen) to 1 (not visible)
  51536. * It helps with side by side comparison against the final render
  51537. * This defaults to -1
  51538. */
  51539. private debugLimit;
  51540. /**
  51541. * @hidden
  51542. * This is reserved for the inspector.
  51543. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51544. * You can use the factor to better multiply the final value.
  51545. */
  51546. private debugFactor;
  51547. /**
  51548. * Defines the clear coat layer parameters for the material.
  51549. */
  51550. readonly clearCoat: PBRClearCoatConfiguration;
  51551. /**
  51552. * Defines the anisotropic parameters for the material.
  51553. */
  51554. readonly anisotropy: PBRAnisotropicConfiguration;
  51555. /**
  51556. * Defines the BRDF parameters for the material.
  51557. */
  51558. readonly brdf: PBRBRDFConfiguration;
  51559. /**
  51560. * Defines the Sheen parameters for the material.
  51561. */
  51562. readonly sheen: PBRSheenConfiguration;
  51563. /**
  51564. * Defines the SubSurface parameters for the material.
  51565. */
  51566. readonly subSurface: PBRSubSurfaceConfiguration;
  51567. /**
  51568. * Custom callback helping to override the default shader used in the material.
  51569. */
  51570. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51571. protected _rebuildInParallel: boolean;
  51572. /**
  51573. * Instantiates a new PBRMaterial instance.
  51574. *
  51575. * @param name The material name
  51576. * @param scene The scene the material will be use in.
  51577. */
  51578. constructor(name: string, scene: Scene);
  51579. /**
  51580. * Gets a boolean indicating that current material needs to register RTT
  51581. */
  51582. get hasRenderTargetTextures(): boolean;
  51583. /**
  51584. * Gets the name of the material class.
  51585. */
  51586. getClassName(): string;
  51587. /**
  51588. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51589. */
  51590. get useLogarithmicDepth(): boolean;
  51591. /**
  51592. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51593. */
  51594. set useLogarithmicDepth(value: boolean);
  51595. /**
  51596. * Returns true if alpha blending should be disabled.
  51597. */
  51598. protected get _disableAlphaBlending(): boolean;
  51599. /**
  51600. * Specifies whether or not this material should be rendered in alpha blend mode.
  51601. */
  51602. needAlphaBlending(): boolean;
  51603. /**
  51604. * Specifies whether or not this material should be rendered in alpha test mode.
  51605. */
  51606. needAlphaTesting(): boolean;
  51607. /**
  51608. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51609. */
  51610. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51611. /**
  51612. * Gets the texture used for the alpha test.
  51613. */
  51614. getAlphaTestTexture(): Nullable<BaseTexture>;
  51615. /**
  51616. * Specifies that the submesh is ready to be used.
  51617. * @param mesh - BJS mesh.
  51618. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51619. * @param useInstances - Specifies that instances should be used.
  51620. * @returns - boolean indicating that the submesh is ready or not.
  51621. */
  51622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51623. /**
  51624. * Specifies if the material uses metallic roughness workflow.
  51625. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51626. */
  51627. isMetallicWorkflow(): boolean;
  51628. private _prepareEffect;
  51629. private _prepareDefines;
  51630. /**
  51631. * Force shader compilation
  51632. */
  51633. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51634. /**
  51635. * Initializes the uniform buffer layout for the shader.
  51636. */
  51637. buildUniformLayout(): void;
  51638. /**
  51639. * Unbinds the material from the mesh
  51640. */
  51641. unbind(): void;
  51642. /**
  51643. * Binds the submesh data.
  51644. * @param world - The world matrix.
  51645. * @param mesh - The BJS mesh.
  51646. * @param subMesh - A submesh of the BJS mesh.
  51647. */
  51648. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51649. /**
  51650. * Returns the animatable textures.
  51651. * @returns - Array of animatable textures.
  51652. */
  51653. getAnimatables(): IAnimatable[];
  51654. /**
  51655. * Returns the texture used for reflections.
  51656. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51657. */
  51658. private _getReflectionTexture;
  51659. /**
  51660. * Returns an array of the actively used textures.
  51661. * @returns - Array of BaseTextures
  51662. */
  51663. getActiveTextures(): BaseTexture[];
  51664. /**
  51665. * Checks to see if a texture is used in the material.
  51666. * @param texture - Base texture to use.
  51667. * @returns - Boolean specifying if a texture is used in the material.
  51668. */
  51669. hasTexture(texture: BaseTexture): boolean;
  51670. /**
  51671. * Disposes the resources of the material.
  51672. * @param forceDisposeEffect - Forces the disposal of effects.
  51673. * @param forceDisposeTextures - Forces the disposal of all textures.
  51674. */
  51675. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51676. }
  51677. }
  51678. declare module BABYLON {
  51679. /**
  51680. * The Physically based material of BJS.
  51681. *
  51682. * This offers the main features of a standard PBR material.
  51683. * For more information, please refer to the documentation :
  51684. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51685. */
  51686. export class PBRMaterial extends PBRBaseMaterial {
  51687. /**
  51688. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51689. */
  51690. static readonly PBRMATERIAL_OPAQUE: number;
  51691. /**
  51692. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51693. */
  51694. static readonly PBRMATERIAL_ALPHATEST: number;
  51695. /**
  51696. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51697. */
  51698. static readonly PBRMATERIAL_ALPHABLEND: number;
  51699. /**
  51700. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51701. * They are also discarded below the alpha cutoff threshold to improve performances.
  51702. */
  51703. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51704. /**
  51705. * Defines the default value of how much AO map is occluding the analytical lights
  51706. * (point spot...).
  51707. */
  51708. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51709. /**
  51710. * Intensity of the direct lights e.g. the four lights available in your scene.
  51711. * This impacts both the direct diffuse and specular highlights.
  51712. */
  51713. directIntensity: number;
  51714. /**
  51715. * Intensity of the emissive part of the material.
  51716. * This helps controlling the emissive effect without modifying the emissive color.
  51717. */
  51718. emissiveIntensity: number;
  51719. /**
  51720. * Intensity of the environment e.g. how much the environment will light the object
  51721. * either through harmonics for rough material or through the refelction for shiny ones.
  51722. */
  51723. environmentIntensity: number;
  51724. /**
  51725. * This is a special control allowing the reduction of the specular highlights coming from the
  51726. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51727. */
  51728. specularIntensity: number;
  51729. /**
  51730. * Debug Control allowing disabling the bump map on this material.
  51731. */
  51732. disableBumpMap: boolean;
  51733. /**
  51734. * AKA Diffuse Texture in standard nomenclature.
  51735. */
  51736. albedoTexture: BaseTexture;
  51737. /**
  51738. * AKA Occlusion Texture in other nomenclature.
  51739. */
  51740. ambientTexture: BaseTexture;
  51741. /**
  51742. * AKA Occlusion Texture Intensity in other nomenclature.
  51743. */
  51744. ambientTextureStrength: number;
  51745. /**
  51746. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51747. * 1 means it completely occludes it
  51748. * 0 mean it has no impact
  51749. */
  51750. ambientTextureImpactOnAnalyticalLights: number;
  51751. /**
  51752. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51753. */
  51754. opacityTexture: BaseTexture;
  51755. /**
  51756. * Stores the reflection values in a texture.
  51757. */
  51758. reflectionTexture: Nullable<BaseTexture>;
  51759. /**
  51760. * Stores the emissive values in a texture.
  51761. */
  51762. emissiveTexture: BaseTexture;
  51763. /**
  51764. * AKA Specular texture in other nomenclature.
  51765. */
  51766. reflectivityTexture: BaseTexture;
  51767. /**
  51768. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51769. */
  51770. metallicTexture: BaseTexture;
  51771. /**
  51772. * Specifies the metallic scalar of the metallic/roughness workflow.
  51773. * Can also be used to scale the metalness values of the metallic texture.
  51774. */
  51775. metallic: Nullable<number>;
  51776. /**
  51777. * Specifies the roughness scalar of the metallic/roughness workflow.
  51778. * Can also be used to scale the roughness values of the metallic texture.
  51779. */
  51780. roughness: Nullable<number>;
  51781. /**
  51782. * Specifies the an F0 factor to help configuring the material F0.
  51783. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51784. * to 0.5 the previously hard coded value stays the same.
  51785. * Can also be used to scale the F0 values of the metallic texture.
  51786. */
  51787. metallicF0Factor: number;
  51788. /**
  51789. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51790. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51791. * your expectation as it multiplies with the texture data.
  51792. */
  51793. useMetallicF0FactorFromMetallicTexture: boolean;
  51794. /**
  51795. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51796. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51797. */
  51798. microSurfaceTexture: BaseTexture;
  51799. /**
  51800. * Stores surface normal data used to displace a mesh in a texture.
  51801. */
  51802. bumpTexture: BaseTexture;
  51803. /**
  51804. * Stores the pre-calculated light information of a mesh in a texture.
  51805. */
  51806. lightmapTexture: BaseTexture;
  51807. /**
  51808. * Stores the refracted light information in a texture.
  51809. */
  51810. get refractionTexture(): Nullable<BaseTexture>;
  51811. set refractionTexture(value: Nullable<BaseTexture>);
  51812. /**
  51813. * The color of a material in ambient lighting.
  51814. */
  51815. ambientColor: Color3;
  51816. /**
  51817. * AKA Diffuse Color in other nomenclature.
  51818. */
  51819. albedoColor: Color3;
  51820. /**
  51821. * AKA Specular Color in other nomenclature.
  51822. */
  51823. reflectivityColor: Color3;
  51824. /**
  51825. * The color reflected from the material.
  51826. */
  51827. reflectionColor: Color3;
  51828. /**
  51829. * The color emitted from the material.
  51830. */
  51831. emissiveColor: Color3;
  51832. /**
  51833. * AKA Glossiness in other nomenclature.
  51834. */
  51835. microSurface: number;
  51836. /**
  51837. * source material index of refraction (IOR)' / 'destination material IOR.
  51838. */
  51839. get indexOfRefraction(): number;
  51840. set indexOfRefraction(value: number);
  51841. /**
  51842. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51843. */
  51844. get invertRefractionY(): boolean;
  51845. set invertRefractionY(value: boolean);
  51846. /**
  51847. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51848. * Materials half opaque for instance using refraction could benefit from this control.
  51849. */
  51850. get linkRefractionWithTransparency(): boolean;
  51851. set linkRefractionWithTransparency(value: boolean);
  51852. /**
  51853. * If true, the light map contains occlusion information instead of lighting info.
  51854. */
  51855. useLightmapAsShadowmap: boolean;
  51856. /**
  51857. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51858. */
  51859. useAlphaFromAlbedoTexture: boolean;
  51860. /**
  51861. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51862. */
  51863. forceAlphaTest: boolean;
  51864. /**
  51865. * Defines the alpha limits in alpha test mode.
  51866. */
  51867. alphaCutOff: number;
  51868. /**
  51869. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51870. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51871. */
  51872. useSpecularOverAlpha: boolean;
  51873. /**
  51874. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51875. */
  51876. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51877. /**
  51878. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51879. */
  51880. useRoughnessFromMetallicTextureAlpha: boolean;
  51881. /**
  51882. * Specifies if the metallic texture contains the roughness information in its green channel.
  51883. */
  51884. useRoughnessFromMetallicTextureGreen: boolean;
  51885. /**
  51886. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51887. */
  51888. useMetallnessFromMetallicTextureBlue: boolean;
  51889. /**
  51890. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51891. */
  51892. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51893. /**
  51894. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51895. */
  51896. useAmbientInGrayScale: boolean;
  51897. /**
  51898. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51899. * The material will try to infer what glossiness each pixel should be.
  51900. */
  51901. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51902. /**
  51903. * BJS is using an harcoded light falloff based on a manually sets up range.
  51904. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51905. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51906. */
  51907. get usePhysicalLightFalloff(): boolean;
  51908. /**
  51909. * BJS is using an harcoded light falloff based on a manually sets up range.
  51910. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51911. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51912. */
  51913. set usePhysicalLightFalloff(value: boolean);
  51914. /**
  51915. * In order to support the falloff compatibility with gltf, a special mode has been added
  51916. * to reproduce the gltf light falloff.
  51917. */
  51918. get useGLTFLightFalloff(): boolean;
  51919. /**
  51920. * In order to support the falloff compatibility with gltf, a special mode has been added
  51921. * to reproduce the gltf light falloff.
  51922. */
  51923. set useGLTFLightFalloff(value: boolean);
  51924. /**
  51925. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51926. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51927. */
  51928. useRadianceOverAlpha: boolean;
  51929. /**
  51930. * Allows using an object space normal map (instead of tangent space).
  51931. */
  51932. useObjectSpaceNormalMap: boolean;
  51933. /**
  51934. * Allows using the bump map in parallax mode.
  51935. */
  51936. useParallax: boolean;
  51937. /**
  51938. * Allows using the bump map in parallax occlusion mode.
  51939. */
  51940. useParallaxOcclusion: boolean;
  51941. /**
  51942. * Controls the scale bias of the parallax mode.
  51943. */
  51944. parallaxScaleBias: number;
  51945. /**
  51946. * If sets to true, disables all the lights affecting the material.
  51947. */
  51948. disableLighting: boolean;
  51949. /**
  51950. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51951. */
  51952. forceIrradianceInFragment: boolean;
  51953. /**
  51954. * Number of Simultaneous lights allowed on the material.
  51955. */
  51956. maxSimultaneousLights: number;
  51957. /**
  51958. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51959. */
  51960. invertNormalMapX: boolean;
  51961. /**
  51962. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51963. */
  51964. invertNormalMapY: boolean;
  51965. /**
  51966. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51967. */
  51968. twoSidedLighting: boolean;
  51969. /**
  51970. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51971. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51972. */
  51973. useAlphaFresnel: boolean;
  51974. /**
  51975. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51976. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51977. */
  51978. useLinearAlphaFresnel: boolean;
  51979. /**
  51980. * Let user defines the brdf lookup texture used for IBL.
  51981. * A default 8bit version is embedded but you could point at :
  51982. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51983. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51984. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51985. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51986. */
  51987. environmentBRDFTexture: Nullable<BaseTexture>;
  51988. /**
  51989. * Force normal to face away from face.
  51990. */
  51991. forceNormalForward: boolean;
  51992. /**
  51993. * Enables specular anti aliasing in the PBR shader.
  51994. * It will both interacts on the Geometry for analytical and IBL lighting.
  51995. * It also prefilter the roughness map based on the bump values.
  51996. */
  51997. enableSpecularAntiAliasing: boolean;
  51998. /**
  51999. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52000. * makes the reflect vector face the model (under horizon).
  52001. */
  52002. useHorizonOcclusion: boolean;
  52003. /**
  52004. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52005. * too much the area relying on ambient texture to define their ambient occlusion.
  52006. */
  52007. useRadianceOcclusion: boolean;
  52008. /**
  52009. * If set to true, no lighting calculations will be applied.
  52010. */
  52011. unlit: boolean;
  52012. /**
  52013. * Gets the image processing configuration used either in this material.
  52014. */
  52015. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52016. /**
  52017. * Sets the Default image processing configuration used either in the this material.
  52018. *
  52019. * If sets to null, the scene one is in use.
  52020. */
  52021. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52022. /**
  52023. * Gets wether the color curves effect is enabled.
  52024. */
  52025. get cameraColorCurvesEnabled(): boolean;
  52026. /**
  52027. * Sets wether the color curves effect is enabled.
  52028. */
  52029. set cameraColorCurvesEnabled(value: boolean);
  52030. /**
  52031. * Gets wether the color grading effect is enabled.
  52032. */
  52033. get cameraColorGradingEnabled(): boolean;
  52034. /**
  52035. * Gets wether the color grading effect is enabled.
  52036. */
  52037. set cameraColorGradingEnabled(value: boolean);
  52038. /**
  52039. * Gets wether tonemapping is enabled or not.
  52040. */
  52041. get cameraToneMappingEnabled(): boolean;
  52042. /**
  52043. * Sets wether tonemapping is enabled or not
  52044. */
  52045. set cameraToneMappingEnabled(value: boolean);
  52046. /**
  52047. * The camera exposure used on this material.
  52048. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52049. * This corresponds to a photographic exposure.
  52050. */
  52051. get cameraExposure(): number;
  52052. /**
  52053. * The camera exposure used on this material.
  52054. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52055. * This corresponds to a photographic exposure.
  52056. */
  52057. set cameraExposure(value: number);
  52058. /**
  52059. * Gets The camera contrast used on this material.
  52060. */
  52061. get cameraContrast(): number;
  52062. /**
  52063. * Sets The camera contrast used on this material.
  52064. */
  52065. set cameraContrast(value: number);
  52066. /**
  52067. * Gets the Color Grading 2D Lookup Texture.
  52068. */
  52069. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52070. /**
  52071. * Sets the Color Grading 2D Lookup Texture.
  52072. */
  52073. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52074. /**
  52075. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52076. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52077. * 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;
  52078. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52079. */
  52080. get cameraColorCurves(): Nullable<ColorCurves>;
  52081. /**
  52082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52084. * 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;
  52085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52086. */
  52087. set cameraColorCurves(value: Nullable<ColorCurves>);
  52088. /**
  52089. * Instantiates a new PBRMaterial instance.
  52090. *
  52091. * @param name The material name
  52092. * @param scene The scene the material will be use in.
  52093. */
  52094. constructor(name: string, scene: Scene);
  52095. /**
  52096. * Returns the name of this material class.
  52097. */
  52098. getClassName(): string;
  52099. /**
  52100. * Makes a duplicate of the current material.
  52101. * @param name - name to use for the new material.
  52102. */
  52103. clone(name: string): PBRMaterial;
  52104. /**
  52105. * Serializes this PBR Material.
  52106. * @returns - An object with the serialized material.
  52107. */
  52108. serialize(): any;
  52109. /**
  52110. * Parses a PBR Material from a serialized object.
  52111. * @param source - Serialized object.
  52112. * @param scene - BJS scene instance.
  52113. * @param rootUrl - url for the scene object
  52114. * @returns - PBRMaterial
  52115. */
  52116. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52117. }
  52118. }
  52119. declare module BABYLON {
  52120. /**
  52121. * Direct draw surface info
  52122. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52123. */
  52124. export interface DDSInfo {
  52125. /**
  52126. * Width of the texture
  52127. */
  52128. width: number;
  52129. /**
  52130. * Width of the texture
  52131. */
  52132. height: number;
  52133. /**
  52134. * Number of Mipmaps for the texture
  52135. * @see https://en.wikipedia.org/wiki/Mipmap
  52136. */
  52137. mipmapCount: number;
  52138. /**
  52139. * If the textures format is a known fourCC format
  52140. * @see https://www.fourcc.org/
  52141. */
  52142. isFourCC: boolean;
  52143. /**
  52144. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52145. */
  52146. isRGB: boolean;
  52147. /**
  52148. * If the texture is a lumincance format
  52149. */
  52150. isLuminance: boolean;
  52151. /**
  52152. * If this is a cube texture
  52153. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52154. */
  52155. isCube: boolean;
  52156. /**
  52157. * If the texture is a compressed format eg. FOURCC_DXT1
  52158. */
  52159. isCompressed: boolean;
  52160. /**
  52161. * The dxgiFormat of the texture
  52162. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52163. */
  52164. dxgiFormat: number;
  52165. /**
  52166. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52167. */
  52168. textureType: number;
  52169. /**
  52170. * Sphericle polynomial created for the dds texture
  52171. */
  52172. sphericalPolynomial?: SphericalPolynomial;
  52173. }
  52174. /**
  52175. * Class used to provide DDS decompression tools
  52176. */
  52177. export class DDSTools {
  52178. /**
  52179. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52180. */
  52181. static StoreLODInAlphaChannel: boolean;
  52182. /**
  52183. * Gets DDS information from an array buffer
  52184. * @param data defines the array buffer view to read data from
  52185. * @returns the DDS information
  52186. */
  52187. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52188. private static _FloatView;
  52189. private static _Int32View;
  52190. private static _ToHalfFloat;
  52191. private static _FromHalfFloat;
  52192. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52193. private static _GetHalfFloatRGBAArrayBuffer;
  52194. private static _GetFloatRGBAArrayBuffer;
  52195. private static _GetFloatAsUIntRGBAArrayBuffer;
  52196. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52197. private static _GetRGBAArrayBuffer;
  52198. private static _ExtractLongWordOrder;
  52199. private static _GetRGBArrayBuffer;
  52200. private static _GetLuminanceArrayBuffer;
  52201. /**
  52202. * Uploads DDS Levels to a Babylon Texture
  52203. * @hidden
  52204. */
  52205. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52206. }
  52207. interface ThinEngine {
  52208. /**
  52209. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52210. * @param rootUrl defines the url where the file to load is located
  52211. * @param scene defines the current scene
  52212. * @param lodScale defines scale to apply to the mip map selection
  52213. * @param lodOffset defines offset to apply to the mip map selection
  52214. * @param onLoad defines an optional callback raised when the texture is loaded
  52215. * @param onError defines an optional callback raised if there is an issue to load the texture
  52216. * @param format defines the format of the data
  52217. * @param forcedExtension defines the extension to use to pick the right loader
  52218. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52219. * @returns the cube texture as an InternalTexture
  52220. */
  52221. 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;
  52222. }
  52223. }
  52224. declare module BABYLON {
  52225. /**
  52226. * Implementation of the DDS Texture Loader.
  52227. * @hidden
  52228. */
  52229. export class _DDSTextureLoader implements IInternalTextureLoader {
  52230. /**
  52231. * Defines wether the loader supports cascade loading the different faces.
  52232. */
  52233. readonly supportCascades: boolean;
  52234. /**
  52235. * This returns if the loader support the current file information.
  52236. * @param extension defines the file extension of the file being loaded
  52237. * @returns true if the loader can load the specified file
  52238. */
  52239. canLoad(extension: string): boolean;
  52240. /**
  52241. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52242. * @param data contains the texture data
  52243. * @param texture defines the BabylonJS internal texture
  52244. * @param createPolynomials will be true if polynomials have been requested
  52245. * @param onLoad defines the callback to trigger once the texture is ready
  52246. * @param onError defines the callback to trigger in case of error
  52247. */
  52248. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52249. /**
  52250. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52251. * @param data contains the texture data
  52252. * @param texture defines the BabylonJS internal texture
  52253. * @param callback defines the method to call once ready to upload
  52254. */
  52255. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52256. }
  52257. }
  52258. declare module BABYLON {
  52259. /**
  52260. * Implementation of the ENV Texture Loader.
  52261. * @hidden
  52262. */
  52263. export class _ENVTextureLoader implements IInternalTextureLoader {
  52264. /**
  52265. * Defines wether the loader supports cascade loading the different faces.
  52266. */
  52267. readonly supportCascades: boolean;
  52268. /**
  52269. * This returns if the loader support the current file information.
  52270. * @param extension defines the file extension of the file being loaded
  52271. * @returns true if the loader can load the specified file
  52272. */
  52273. canLoad(extension: string): boolean;
  52274. /**
  52275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52276. * @param data contains the texture data
  52277. * @param texture defines the BabylonJS internal texture
  52278. * @param createPolynomials will be true if polynomials have been requested
  52279. * @param onLoad defines the callback to trigger once the texture is ready
  52280. * @param onError defines the callback to trigger in case of error
  52281. */
  52282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52283. /**
  52284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52285. * @param data contains the texture data
  52286. * @param texture defines the BabylonJS internal texture
  52287. * @param callback defines the method to call once ready to upload
  52288. */
  52289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52290. }
  52291. }
  52292. declare module BABYLON {
  52293. /**
  52294. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52295. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52296. */
  52297. export class KhronosTextureContainer {
  52298. /** contents of the KTX container file */
  52299. data: ArrayBufferView;
  52300. private static HEADER_LEN;
  52301. private static COMPRESSED_2D;
  52302. private static COMPRESSED_3D;
  52303. private static TEX_2D;
  52304. private static TEX_3D;
  52305. /**
  52306. * Gets the openGL type
  52307. */
  52308. glType: number;
  52309. /**
  52310. * Gets the openGL type size
  52311. */
  52312. glTypeSize: number;
  52313. /**
  52314. * Gets the openGL format
  52315. */
  52316. glFormat: number;
  52317. /**
  52318. * Gets the openGL internal format
  52319. */
  52320. glInternalFormat: number;
  52321. /**
  52322. * Gets the base internal format
  52323. */
  52324. glBaseInternalFormat: number;
  52325. /**
  52326. * Gets image width in pixel
  52327. */
  52328. pixelWidth: number;
  52329. /**
  52330. * Gets image height in pixel
  52331. */
  52332. pixelHeight: number;
  52333. /**
  52334. * Gets image depth in pixels
  52335. */
  52336. pixelDepth: number;
  52337. /**
  52338. * Gets the number of array elements
  52339. */
  52340. numberOfArrayElements: number;
  52341. /**
  52342. * Gets the number of faces
  52343. */
  52344. numberOfFaces: number;
  52345. /**
  52346. * Gets the number of mipmap levels
  52347. */
  52348. numberOfMipmapLevels: number;
  52349. /**
  52350. * Gets the bytes of key value data
  52351. */
  52352. bytesOfKeyValueData: number;
  52353. /**
  52354. * Gets the load type
  52355. */
  52356. loadType: number;
  52357. /**
  52358. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52359. */
  52360. isInvalid: boolean;
  52361. /**
  52362. * Creates a new KhronosTextureContainer
  52363. * @param data contents of the KTX container file
  52364. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52365. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52366. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52367. */
  52368. constructor(
  52369. /** contents of the KTX container file */
  52370. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52371. /**
  52372. * Uploads KTX content to a Babylon Texture.
  52373. * It is assumed that the texture has already been created & is currently bound
  52374. * @hidden
  52375. */
  52376. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52377. private _upload2DCompressedLevels;
  52378. /**
  52379. * Checks if the given data starts with a KTX file identifier.
  52380. * @param data the data to check
  52381. * @returns true if the data is a KTX file or false otherwise
  52382. */
  52383. static IsValid(data: ArrayBufferView): boolean;
  52384. }
  52385. }
  52386. declare module BABYLON {
  52387. /**
  52388. * Class for loading KTX2 files
  52389. * !!! Experimental Extension Subject to Changes !!!
  52390. * @hidden
  52391. */
  52392. export class KhronosTextureContainer2 {
  52393. private static _ModulePromise;
  52394. private static _TranscodeFormat;
  52395. constructor(engine: ThinEngine);
  52396. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52397. private _determineTranscodeFormat;
  52398. /**
  52399. * Checks if the given data starts with a KTX2 file identifier.
  52400. * @param data the data to check
  52401. * @returns true if the data is a KTX2 file or false otherwise
  52402. */
  52403. static IsValid(data: ArrayBufferView): boolean;
  52404. }
  52405. }
  52406. declare module BABYLON {
  52407. /**
  52408. * Implementation of the KTX Texture Loader.
  52409. * @hidden
  52410. */
  52411. export class _KTXTextureLoader implements IInternalTextureLoader {
  52412. /**
  52413. * Defines wether the loader supports cascade loading the different faces.
  52414. */
  52415. readonly supportCascades: boolean;
  52416. /**
  52417. * This returns if the loader support the current file information.
  52418. * @param extension defines the file extension of the file being loaded
  52419. * @returns true if the loader can load the specified file
  52420. */
  52421. canLoad(extension: string): boolean;
  52422. /**
  52423. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52424. * @param data contains the texture data
  52425. * @param texture defines the BabylonJS internal texture
  52426. * @param createPolynomials will be true if polynomials have been requested
  52427. * @param onLoad defines the callback to trigger once the texture is ready
  52428. * @param onError defines the callback to trigger in case of error
  52429. */
  52430. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52431. /**
  52432. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52433. * @param data contains the texture data
  52434. * @param texture defines the BabylonJS internal texture
  52435. * @param callback defines the method to call once ready to upload
  52436. */
  52437. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52438. }
  52439. }
  52440. declare module BABYLON {
  52441. /** @hidden */
  52442. export var _forceSceneHelpersToBundle: boolean;
  52443. interface Scene {
  52444. /**
  52445. * Creates a default light for the scene.
  52446. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52447. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52448. */
  52449. createDefaultLight(replace?: boolean): void;
  52450. /**
  52451. * Creates a default camera for the scene.
  52452. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52453. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52454. * @param replace has default false, when true replaces the active camera in the scene
  52455. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52456. */
  52457. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52458. /**
  52459. * Creates a default camera and a default light.
  52460. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52461. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52462. * @param replace has the default false, when true replaces the active camera/light in the scene
  52463. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52464. */
  52465. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52466. /**
  52467. * Creates a new sky box
  52468. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52469. * @param environmentTexture defines the texture to use as environment texture
  52470. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52471. * @param scale defines the overall scale of the skybox
  52472. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52473. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52474. * @returns a new mesh holding the sky box
  52475. */
  52476. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52477. /**
  52478. * Creates a new environment
  52479. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52480. * @param options defines the options you can use to configure the environment
  52481. * @returns the new EnvironmentHelper
  52482. */
  52483. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52484. /**
  52485. * Creates a new VREXperienceHelper
  52486. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52487. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52488. * @returns a new VREXperienceHelper
  52489. */
  52490. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52491. /**
  52492. * Creates a new WebXRDefaultExperience
  52493. * @see http://doc.babylonjs.com/how_to/webxr
  52494. * @param options experience options
  52495. * @returns a promise for a new WebXRDefaultExperience
  52496. */
  52497. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52498. }
  52499. }
  52500. declare module BABYLON {
  52501. /**
  52502. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52503. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52504. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52505. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52506. */
  52507. export class VideoDome extends TransformNode {
  52508. /**
  52509. * Define the video source as a Monoscopic panoramic 360 video.
  52510. */
  52511. static readonly MODE_MONOSCOPIC: number;
  52512. /**
  52513. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52514. */
  52515. static readonly MODE_TOPBOTTOM: number;
  52516. /**
  52517. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52518. */
  52519. static readonly MODE_SIDEBYSIDE: number;
  52520. private _halfDome;
  52521. private _useDirectMapping;
  52522. /**
  52523. * The video texture being displayed on the sphere
  52524. */
  52525. protected _videoTexture: VideoTexture;
  52526. /**
  52527. * Gets the video texture being displayed on the sphere
  52528. */
  52529. get videoTexture(): VideoTexture;
  52530. /**
  52531. * The skybox material
  52532. */
  52533. protected _material: BackgroundMaterial;
  52534. /**
  52535. * The surface used for the skybox
  52536. */
  52537. protected _mesh: Mesh;
  52538. /**
  52539. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52540. */
  52541. private _halfDomeMask;
  52542. /**
  52543. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52544. * Also see the options.resolution property.
  52545. */
  52546. get fovMultiplier(): number;
  52547. set fovMultiplier(value: number);
  52548. private _videoMode;
  52549. /**
  52550. * Gets or set the current video mode for the video. It can be:
  52551. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52552. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52553. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52554. */
  52555. get videoMode(): number;
  52556. set videoMode(value: number);
  52557. /**
  52558. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52559. *
  52560. */
  52561. get halfDome(): boolean;
  52562. /**
  52563. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52564. */
  52565. set halfDome(enabled: boolean);
  52566. /**
  52567. * Oberserver used in Stereoscopic VR Mode.
  52568. */
  52569. private _onBeforeCameraRenderObserver;
  52570. /**
  52571. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52572. * @param name Element's name, child elements will append suffixes for their own names.
  52573. * @param urlsOrVideo defines the url(s) or the video element to use
  52574. * @param options An object containing optional or exposed sub element properties
  52575. */
  52576. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52577. resolution?: number;
  52578. clickToPlay?: boolean;
  52579. autoPlay?: boolean;
  52580. loop?: boolean;
  52581. size?: number;
  52582. poster?: string;
  52583. faceForward?: boolean;
  52584. useDirectMapping?: boolean;
  52585. halfDomeMode?: boolean;
  52586. }, scene: Scene);
  52587. private _changeVideoMode;
  52588. /**
  52589. * Releases resources associated with this node.
  52590. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52591. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52592. */
  52593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /**
  52598. * This class can be used to get instrumentation data from a Babylon engine
  52599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52600. */
  52601. export class EngineInstrumentation implements IDisposable {
  52602. /**
  52603. * Define the instrumented engine.
  52604. */
  52605. engine: Engine;
  52606. private _captureGPUFrameTime;
  52607. private _gpuFrameTimeToken;
  52608. private _gpuFrameTime;
  52609. private _captureShaderCompilationTime;
  52610. private _shaderCompilationTime;
  52611. private _onBeginFrameObserver;
  52612. private _onEndFrameObserver;
  52613. private _onBeforeShaderCompilationObserver;
  52614. private _onAfterShaderCompilationObserver;
  52615. /**
  52616. * Gets the perf counter used for GPU frame time
  52617. */
  52618. get gpuFrameTimeCounter(): PerfCounter;
  52619. /**
  52620. * Gets the GPU frame time capture status
  52621. */
  52622. get captureGPUFrameTime(): boolean;
  52623. /**
  52624. * Enable or disable the GPU frame time capture
  52625. */
  52626. set captureGPUFrameTime(value: boolean);
  52627. /**
  52628. * Gets the perf counter used for shader compilation time
  52629. */
  52630. get shaderCompilationTimeCounter(): PerfCounter;
  52631. /**
  52632. * Gets the shader compilation time capture status
  52633. */
  52634. get captureShaderCompilationTime(): boolean;
  52635. /**
  52636. * Enable or disable the shader compilation time capture
  52637. */
  52638. set captureShaderCompilationTime(value: boolean);
  52639. /**
  52640. * Instantiates a new engine instrumentation.
  52641. * This class can be used to get instrumentation data from a Babylon engine
  52642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52643. * @param engine Defines the engine to instrument
  52644. */
  52645. constructor(
  52646. /**
  52647. * Define the instrumented engine.
  52648. */
  52649. engine: Engine);
  52650. /**
  52651. * Dispose and release associated resources.
  52652. */
  52653. dispose(): void;
  52654. }
  52655. }
  52656. declare module BABYLON {
  52657. /**
  52658. * This class can be used to get instrumentation data from a Babylon engine
  52659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52660. */
  52661. export class SceneInstrumentation implements IDisposable {
  52662. /**
  52663. * Defines the scene to instrument
  52664. */
  52665. scene: Scene;
  52666. private _captureActiveMeshesEvaluationTime;
  52667. private _activeMeshesEvaluationTime;
  52668. private _captureRenderTargetsRenderTime;
  52669. private _renderTargetsRenderTime;
  52670. private _captureFrameTime;
  52671. private _frameTime;
  52672. private _captureRenderTime;
  52673. private _renderTime;
  52674. private _captureInterFrameTime;
  52675. private _interFrameTime;
  52676. private _captureParticlesRenderTime;
  52677. private _particlesRenderTime;
  52678. private _captureSpritesRenderTime;
  52679. private _spritesRenderTime;
  52680. private _capturePhysicsTime;
  52681. private _physicsTime;
  52682. private _captureAnimationsTime;
  52683. private _animationsTime;
  52684. private _captureCameraRenderTime;
  52685. private _cameraRenderTime;
  52686. private _onBeforeActiveMeshesEvaluationObserver;
  52687. private _onAfterActiveMeshesEvaluationObserver;
  52688. private _onBeforeRenderTargetsRenderObserver;
  52689. private _onAfterRenderTargetsRenderObserver;
  52690. private _onAfterRenderObserver;
  52691. private _onBeforeDrawPhaseObserver;
  52692. private _onAfterDrawPhaseObserver;
  52693. private _onBeforeAnimationsObserver;
  52694. private _onBeforeParticlesRenderingObserver;
  52695. private _onAfterParticlesRenderingObserver;
  52696. private _onBeforeSpritesRenderingObserver;
  52697. private _onAfterSpritesRenderingObserver;
  52698. private _onBeforePhysicsObserver;
  52699. private _onAfterPhysicsObserver;
  52700. private _onAfterAnimationsObserver;
  52701. private _onBeforeCameraRenderObserver;
  52702. private _onAfterCameraRenderObserver;
  52703. /**
  52704. * Gets the perf counter used for active meshes evaluation time
  52705. */
  52706. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52707. /**
  52708. * Gets the active meshes evaluation time capture status
  52709. */
  52710. get captureActiveMeshesEvaluationTime(): boolean;
  52711. /**
  52712. * Enable or disable the active meshes evaluation time capture
  52713. */
  52714. set captureActiveMeshesEvaluationTime(value: boolean);
  52715. /**
  52716. * Gets the perf counter used for render targets render time
  52717. */
  52718. get renderTargetsRenderTimeCounter(): PerfCounter;
  52719. /**
  52720. * Gets the render targets render time capture status
  52721. */
  52722. get captureRenderTargetsRenderTime(): boolean;
  52723. /**
  52724. * Enable or disable the render targets render time capture
  52725. */
  52726. set captureRenderTargetsRenderTime(value: boolean);
  52727. /**
  52728. * Gets the perf counter used for particles render time
  52729. */
  52730. get particlesRenderTimeCounter(): PerfCounter;
  52731. /**
  52732. * Gets the particles render time capture status
  52733. */
  52734. get captureParticlesRenderTime(): boolean;
  52735. /**
  52736. * Enable or disable the particles render time capture
  52737. */
  52738. set captureParticlesRenderTime(value: boolean);
  52739. /**
  52740. * Gets the perf counter used for sprites render time
  52741. */
  52742. get spritesRenderTimeCounter(): PerfCounter;
  52743. /**
  52744. * Gets the sprites render time capture status
  52745. */
  52746. get captureSpritesRenderTime(): boolean;
  52747. /**
  52748. * Enable or disable the sprites render time capture
  52749. */
  52750. set captureSpritesRenderTime(value: boolean);
  52751. /**
  52752. * Gets the perf counter used for physics time
  52753. */
  52754. get physicsTimeCounter(): PerfCounter;
  52755. /**
  52756. * Gets the physics time capture status
  52757. */
  52758. get capturePhysicsTime(): boolean;
  52759. /**
  52760. * Enable or disable the physics time capture
  52761. */
  52762. set capturePhysicsTime(value: boolean);
  52763. /**
  52764. * Gets the perf counter used for animations time
  52765. */
  52766. get animationsTimeCounter(): PerfCounter;
  52767. /**
  52768. * Gets the animations time capture status
  52769. */
  52770. get captureAnimationsTime(): boolean;
  52771. /**
  52772. * Enable or disable the animations time capture
  52773. */
  52774. set captureAnimationsTime(value: boolean);
  52775. /**
  52776. * Gets the perf counter used for frame time capture
  52777. */
  52778. get frameTimeCounter(): PerfCounter;
  52779. /**
  52780. * Gets the frame time capture status
  52781. */
  52782. get captureFrameTime(): boolean;
  52783. /**
  52784. * Enable or disable the frame time capture
  52785. */
  52786. set captureFrameTime(value: boolean);
  52787. /**
  52788. * Gets the perf counter used for inter-frames time capture
  52789. */
  52790. get interFrameTimeCounter(): PerfCounter;
  52791. /**
  52792. * Gets the inter-frames time capture status
  52793. */
  52794. get captureInterFrameTime(): boolean;
  52795. /**
  52796. * Enable or disable the inter-frames time capture
  52797. */
  52798. set captureInterFrameTime(value: boolean);
  52799. /**
  52800. * Gets the perf counter used for render time capture
  52801. */
  52802. get renderTimeCounter(): PerfCounter;
  52803. /**
  52804. * Gets the render time capture status
  52805. */
  52806. get captureRenderTime(): boolean;
  52807. /**
  52808. * Enable or disable the render time capture
  52809. */
  52810. set captureRenderTime(value: boolean);
  52811. /**
  52812. * Gets the perf counter used for camera render time capture
  52813. */
  52814. get cameraRenderTimeCounter(): PerfCounter;
  52815. /**
  52816. * Gets the camera render time capture status
  52817. */
  52818. get captureCameraRenderTime(): boolean;
  52819. /**
  52820. * Enable or disable the camera render time capture
  52821. */
  52822. set captureCameraRenderTime(value: boolean);
  52823. /**
  52824. * Gets the perf counter used for draw calls
  52825. */
  52826. get drawCallsCounter(): PerfCounter;
  52827. /**
  52828. * Instantiates a new scene instrumentation.
  52829. * This class can be used to get instrumentation data from a Babylon engine
  52830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52831. * @param scene Defines the scene to instrument
  52832. */
  52833. constructor(
  52834. /**
  52835. * Defines the scene to instrument
  52836. */
  52837. scene: Scene);
  52838. /**
  52839. * Dispose and release associated resources.
  52840. */
  52841. dispose(): void;
  52842. }
  52843. }
  52844. declare module BABYLON {
  52845. /** @hidden */
  52846. export var glowMapGenerationPixelShader: {
  52847. name: string;
  52848. shader: string;
  52849. };
  52850. }
  52851. declare module BABYLON {
  52852. /** @hidden */
  52853. export var glowMapGenerationVertexShader: {
  52854. name: string;
  52855. shader: string;
  52856. };
  52857. }
  52858. declare module BABYLON {
  52859. /**
  52860. * Effect layer options. This helps customizing the behaviour
  52861. * of the effect layer.
  52862. */
  52863. export interface IEffectLayerOptions {
  52864. /**
  52865. * Multiplication factor apply to the canvas size to compute the render target size
  52866. * used to generated the objects (the smaller the faster).
  52867. */
  52868. mainTextureRatio: number;
  52869. /**
  52870. * Enforces a fixed size texture to ensure effect stability across devices.
  52871. */
  52872. mainTextureFixedSize?: number;
  52873. /**
  52874. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52875. */
  52876. alphaBlendingMode: number;
  52877. /**
  52878. * The camera attached to the layer.
  52879. */
  52880. camera: Nullable<Camera>;
  52881. /**
  52882. * The rendering group to draw the layer in.
  52883. */
  52884. renderingGroupId: number;
  52885. }
  52886. /**
  52887. * The effect layer Helps adding post process effect blended with the main pass.
  52888. *
  52889. * This can be for instance use to generate glow or higlight effects on the scene.
  52890. *
  52891. * The effect layer class can not be used directly and is intented to inherited from to be
  52892. * customized per effects.
  52893. */
  52894. export abstract class EffectLayer {
  52895. private _vertexBuffers;
  52896. private _indexBuffer;
  52897. private _cachedDefines;
  52898. private _effectLayerMapGenerationEffect;
  52899. private _effectLayerOptions;
  52900. private _mergeEffect;
  52901. protected _scene: Scene;
  52902. protected _engine: Engine;
  52903. protected _maxSize: number;
  52904. protected _mainTextureDesiredSize: ISize;
  52905. protected _mainTexture: RenderTargetTexture;
  52906. protected _shouldRender: boolean;
  52907. protected _postProcesses: PostProcess[];
  52908. protected _textures: BaseTexture[];
  52909. protected _emissiveTextureAndColor: {
  52910. texture: Nullable<BaseTexture>;
  52911. color: Color4;
  52912. };
  52913. /**
  52914. * The name of the layer
  52915. */
  52916. name: string;
  52917. /**
  52918. * The clear color of the texture used to generate the glow map.
  52919. */
  52920. neutralColor: Color4;
  52921. /**
  52922. * Specifies whether the highlight layer is enabled or not.
  52923. */
  52924. isEnabled: boolean;
  52925. /**
  52926. * Gets the camera attached to the layer.
  52927. */
  52928. get camera(): Nullable<Camera>;
  52929. /**
  52930. * Gets the rendering group id the layer should render in.
  52931. */
  52932. get renderingGroupId(): number;
  52933. set renderingGroupId(renderingGroupId: number);
  52934. /**
  52935. * An event triggered when the effect layer has been disposed.
  52936. */
  52937. onDisposeObservable: Observable<EffectLayer>;
  52938. /**
  52939. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52940. */
  52941. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52942. /**
  52943. * An event triggered when the generated texture is being merged in the scene.
  52944. */
  52945. onBeforeComposeObservable: Observable<EffectLayer>;
  52946. /**
  52947. * An event triggered when the mesh is rendered into the effect render target.
  52948. */
  52949. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52950. /**
  52951. * An event triggered after the mesh has been rendered into the effect render target.
  52952. */
  52953. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52954. /**
  52955. * An event triggered when the generated texture has been merged in the scene.
  52956. */
  52957. onAfterComposeObservable: Observable<EffectLayer>;
  52958. /**
  52959. * An event triggered when the efffect layer changes its size.
  52960. */
  52961. onSizeChangedObservable: Observable<EffectLayer>;
  52962. /** @hidden */
  52963. static _SceneComponentInitialization: (scene: Scene) => void;
  52964. /**
  52965. * Instantiates a new effect Layer and references it in the scene.
  52966. * @param name The name of the layer
  52967. * @param scene The scene to use the layer in
  52968. */
  52969. constructor(
  52970. /** The Friendly of the effect in the scene */
  52971. name: string, scene: Scene);
  52972. /**
  52973. * Get the effect name of the layer.
  52974. * @return The effect name
  52975. */
  52976. abstract getEffectName(): string;
  52977. /**
  52978. * Checks for the readiness of the element composing the layer.
  52979. * @param subMesh the mesh to check for
  52980. * @param useInstances specify whether or not to use instances to render the mesh
  52981. * @return true if ready otherwise, false
  52982. */
  52983. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52984. /**
  52985. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52986. * @returns true if the effect requires stencil during the main canvas render pass.
  52987. */
  52988. abstract needStencil(): boolean;
  52989. /**
  52990. * Create the merge effect. This is the shader use to blit the information back
  52991. * to the main canvas at the end of the scene rendering.
  52992. * @returns The effect containing the shader used to merge the effect on the main canvas
  52993. */
  52994. protected abstract _createMergeEffect(): Effect;
  52995. /**
  52996. * Creates the render target textures and post processes used in the effect layer.
  52997. */
  52998. protected abstract _createTextureAndPostProcesses(): void;
  52999. /**
  53000. * Implementation specific of rendering the generating effect on the main canvas.
  53001. * @param effect The effect used to render through
  53002. */
  53003. protected abstract _internalRender(effect: Effect): void;
  53004. /**
  53005. * Sets the required values for both the emissive texture and and the main color.
  53006. */
  53007. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53008. /**
  53009. * Free any resources and references associated to a mesh.
  53010. * Internal use
  53011. * @param mesh The mesh to free.
  53012. */
  53013. abstract _disposeMesh(mesh: Mesh): void;
  53014. /**
  53015. * Serializes this layer (Glow or Highlight for example)
  53016. * @returns a serialized layer object
  53017. */
  53018. abstract serialize?(): any;
  53019. /**
  53020. * Initializes the effect layer with the required options.
  53021. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53022. */
  53023. protected _init(options: Partial<IEffectLayerOptions>): void;
  53024. /**
  53025. * Generates the index buffer of the full screen quad blending to the main canvas.
  53026. */
  53027. private _generateIndexBuffer;
  53028. /**
  53029. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53030. */
  53031. private _generateVertexBuffer;
  53032. /**
  53033. * Sets the main texture desired size which is the closest power of two
  53034. * of the engine canvas size.
  53035. */
  53036. private _setMainTextureSize;
  53037. /**
  53038. * Creates the main texture for the effect layer.
  53039. */
  53040. protected _createMainTexture(): void;
  53041. /**
  53042. * Adds specific effects defines.
  53043. * @param defines The defines to add specifics to.
  53044. */
  53045. protected _addCustomEffectDefines(defines: string[]): void;
  53046. /**
  53047. * Checks for the readiness of the element composing the layer.
  53048. * @param subMesh the mesh to check for
  53049. * @param useInstances specify whether or not to use instances to render the mesh
  53050. * @param emissiveTexture the associated emissive texture used to generate the glow
  53051. * @return true if ready otherwise, false
  53052. */
  53053. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53054. /**
  53055. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53056. */
  53057. render(): void;
  53058. /**
  53059. * Determine if a given mesh will be used in the current effect.
  53060. * @param mesh mesh to test
  53061. * @returns true if the mesh will be used
  53062. */
  53063. hasMesh(mesh: AbstractMesh): boolean;
  53064. /**
  53065. * Returns true if the layer contains information to display, otherwise false.
  53066. * @returns true if the glow layer should be rendered
  53067. */
  53068. shouldRender(): boolean;
  53069. /**
  53070. * Returns true if the mesh should render, otherwise false.
  53071. * @param mesh The mesh to render
  53072. * @returns true if it should render otherwise false
  53073. */
  53074. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53075. /**
  53076. * Returns true if the mesh can be rendered, otherwise false.
  53077. * @param mesh The mesh to render
  53078. * @param material The material used on the mesh
  53079. * @returns true if it can be rendered otherwise false
  53080. */
  53081. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53082. /**
  53083. * Returns true if the mesh should render, otherwise false.
  53084. * @param mesh The mesh to render
  53085. * @returns true if it should render otherwise false
  53086. */
  53087. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53088. /**
  53089. * Renders the submesh passed in parameter to the generation map.
  53090. */
  53091. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53092. /**
  53093. * Defines whether the current material of the mesh should be use to render the effect.
  53094. * @param mesh defines the current mesh to render
  53095. */
  53096. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53097. /**
  53098. * Rebuild the required buffers.
  53099. * @hidden Internal use only.
  53100. */
  53101. _rebuild(): void;
  53102. /**
  53103. * Dispose only the render target textures and post process.
  53104. */
  53105. private _disposeTextureAndPostProcesses;
  53106. /**
  53107. * Dispose the highlight layer and free resources.
  53108. */
  53109. dispose(): void;
  53110. /**
  53111. * Gets the class name of the effect layer
  53112. * @returns the string with the class name of the effect layer
  53113. */
  53114. getClassName(): string;
  53115. /**
  53116. * Creates an effect layer from parsed effect layer data
  53117. * @param parsedEffectLayer defines effect layer data
  53118. * @param scene defines the current scene
  53119. * @param rootUrl defines the root URL containing the effect layer information
  53120. * @returns a parsed effect Layer
  53121. */
  53122. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53123. }
  53124. }
  53125. declare module BABYLON {
  53126. interface AbstractScene {
  53127. /**
  53128. * The list of effect layers (highlights/glow) added to the scene
  53129. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53130. * @see http://doc.babylonjs.com/how_to/glow_layer
  53131. */
  53132. effectLayers: Array<EffectLayer>;
  53133. /**
  53134. * Removes the given effect layer from this scene.
  53135. * @param toRemove defines the effect layer to remove
  53136. * @returns the index of the removed effect layer
  53137. */
  53138. removeEffectLayer(toRemove: EffectLayer): number;
  53139. /**
  53140. * Adds the given effect layer to this scene
  53141. * @param newEffectLayer defines the effect layer to add
  53142. */
  53143. addEffectLayer(newEffectLayer: EffectLayer): void;
  53144. }
  53145. /**
  53146. * Defines the layer scene component responsible to manage any effect layers
  53147. * in a given scene.
  53148. */
  53149. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53150. /**
  53151. * The component name helpfull to identify the component in the list of scene components.
  53152. */
  53153. readonly name: string;
  53154. /**
  53155. * The scene the component belongs to.
  53156. */
  53157. scene: Scene;
  53158. private _engine;
  53159. private _renderEffects;
  53160. private _needStencil;
  53161. private _previousStencilState;
  53162. /**
  53163. * Creates a new instance of the component for the given scene
  53164. * @param scene Defines the scene to register the component in
  53165. */
  53166. constructor(scene: Scene);
  53167. /**
  53168. * Registers the component in a given scene
  53169. */
  53170. register(): void;
  53171. /**
  53172. * Rebuilds the elements related to this component in case of
  53173. * context lost for instance.
  53174. */
  53175. rebuild(): void;
  53176. /**
  53177. * Serializes the component data to the specified json object
  53178. * @param serializationObject The object to serialize to
  53179. */
  53180. serialize(serializationObject: any): void;
  53181. /**
  53182. * Adds all the elements from the container to the scene
  53183. * @param container the container holding the elements
  53184. */
  53185. addFromContainer(container: AbstractScene): void;
  53186. /**
  53187. * Removes all the elements in the container from the scene
  53188. * @param container contains the elements to remove
  53189. * @param dispose if the removed element should be disposed (default: false)
  53190. */
  53191. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53192. /**
  53193. * Disposes the component and the associated ressources.
  53194. */
  53195. dispose(): void;
  53196. private _isReadyForMesh;
  53197. private _renderMainTexture;
  53198. private _setStencil;
  53199. private _setStencilBack;
  53200. private _draw;
  53201. private _drawCamera;
  53202. private _drawRenderingGroup;
  53203. }
  53204. }
  53205. declare module BABYLON {
  53206. /** @hidden */
  53207. export var glowMapMergePixelShader: {
  53208. name: string;
  53209. shader: string;
  53210. };
  53211. }
  53212. declare module BABYLON {
  53213. /** @hidden */
  53214. export var glowMapMergeVertexShader: {
  53215. name: string;
  53216. shader: string;
  53217. };
  53218. }
  53219. declare module BABYLON {
  53220. interface AbstractScene {
  53221. /**
  53222. * Return a the first highlight layer of the scene with a given name.
  53223. * @param name The name of the highlight layer to look for.
  53224. * @return The highlight layer if found otherwise null.
  53225. */
  53226. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53227. }
  53228. /**
  53229. * Glow layer options. This helps customizing the behaviour
  53230. * of the glow layer.
  53231. */
  53232. export interface IGlowLayerOptions {
  53233. /**
  53234. * Multiplication factor apply to the canvas size to compute the render target size
  53235. * used to generated the glowing objects (the smaller the faster).
  53236. */
  53237. mainTextureRatio: number;
  53238. /**
  53239. * Enforces a fixed size texture to ensure resize independant blur.
  53240. */
  53241. mainTextureFixedSize?: number;
  53242. /**
  53243. * How big is the kernel of the blur texture.
  53244. */
  53245. blurKernelSize: number;
  53246. /**
  53247. * The camera attached to the layer.
  53248. */
  53249. camera: Nullable<Camera>;
  53250. /**
  53251. * Enable MSAA by chosing the number of samples.
  53252. */
  53253. mainTextureSamples?: number;
  53254. /**
  53255. * The rendering group to draw the layer in.
  53256. */
  53257. renderingGroupId: number;
  53258. }
  53259. /**
  53260. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53261. *
  53262. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53263. *
  53264. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53265. */
  53266. export class GlowLayer extends EffectLayer {
  53267. /**
  53268. * Effect Name of the layer.
  53269. */
  53270. static readonly EffectName: string;
  53271. /**
  53272. * The default blur kernel size used for the glow.
  53273. */
  53274. static DefaultBlurKernelSize: number;
  53275. /**
  53276. * The default texture size ratio used for the glow.
  53277. */
  53278. static DefaultTextureRatio: number;
  53279. /**
  53280. * Sets the kernel size of the blur.
  53281. */
  53282. set blurKernelSize(value: number);
  53283. /**
  53284. * Gets the kernel size of the blur.
  53285. */
  53286. get blurKernelSize(): number;
  53287. /**
  53288. * Sets the glow intensity.
  53289. */
  53290. set intensity(value: number);
  53291. /**
  53292. * Gets the glow intensity.
  53293. */
  53294. get intensity(): number;
  53295. private _options;
  53296. private _intensity;
  53297. private _horizontalBlurPostprocess1;
  53298. private _verticalBlurPostprocess1;
  53299. private _horizontalBlurPostprocess2;
  53300. private _verticalBlurPostprocess2;
  53301. private _blurTexture1;
  53302. private _blurTexture2;
  53303. private _postProcesses1;
  53304. private _postProcesses2;
  53305. private _includedOnlyMeshes;
  53306. private _excludedMeshes;
  53307. private _meshesUsingTheirOwnMaterials;
  53308. /**
  53309. * Callback used to let the user override the color selection on a per mesh basis
  53310. */
  53311. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53312. /**
  53313. * Callback used to let the user override the texture selection on a per mesh basis
  53314. */
  53315. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53316. /**
  53317. * Instantiates a new glow Layer and references it to the scene.
  53318. * @param name The name of the layer
  53319. * @param scene The scene to use the layer in
  53320. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53321. */
  53322. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53323. /**
  53324. * Get the effect name of the layer.
  53325. * @return The effect name
  53326. */
  53327. getEffectName(): string;
  53328. /**
  53329. * Create the merge effect. This is the shader use to blit the information back
  53330. * to the main canvas at the end of the scene rendering.
  53331. */
  53332. protected _createMergeEffect(): Effect;
  53333. /**
  53334. * Creates the render target textures and post processes used in the glow layer.
  53335. */
  53336. protected _createTextureAndPostProcesses(): void;
  53337. /**
  53338. * Checks for the readiness of the element composing the layer.
  53339. * @param subMesh the mesh to check for
  53340. * @param useInstances specify wether or not to use instances to render the mesh
  53341. * @param emissiveTexture the associated emissive texture used to generate the glow
  53342. * @return true if ready otherwise, false
  53343. */
  53344. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53345. /**
  53346. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53347. */
  53348. needStencil(): boolean;
  53349. /**
  53350. * Returns true if the mesh can be rendered, otherwise false.
  53351. * @param mesh The mesh to render
  53352. * @param material The material used on the mesh
  53353. * @returns true if it can be rendered otherwise false
  53354. */
  53355. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53356. /**
  53357. * Implementation specific of rendering the generating effect on the main canvas.
  53358. * @param effect The effect used to render through
  53359. */
  53360. protected _internalRender(effect: Effect): void;
  53361. /**
  53362. * Sets the required values for both the emissive texture and and the main color.
  53363. */
  53364. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53365. /**
  53366. * Returns true if the mesh should render, otherwise false.
  53367. * @param mesh The mesh to render
  53368. * @returns true if it should render otherwise false
  53369. */
  53370. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53371. /**
  53372. * Adds specific effects defines.
  53373. * @param defines The defines to add specifics to.
  53374. */
  53375. protected _addCustomEffectDefines(defines: string[]): void;
  53376. /**
  53377. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53378. * @param mesh The mesh to exclude from the glow layer
  53379. */
  53380. addExcludedMesh(mesh: Mesh): void;
  53381. /**
  53382. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53383. * @param mesh The mesh to remove
  53384. */
  53385. removeExcludedMesh(mesh: Mesh): void;
  53386. /**
  53387. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53388. * @param mesh The mesh to include in the glow layer
  53389. */
  53390. addIncludedOnlyMesh(mesh: Mesh): void;
  53391. /**
  53392. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53393. * @param mesh The mesh to remove
  53394. */
  53395. removeIncludedOnlyMesh(mesh: Mesh): void;
  53396. /**
  53397. * Determine if a given mesh will be used in the glow layer
  53398. * @param mesh The mesh to test
  53399. * @returns true if the mesh will be highlighted by the current glow layer
  53400. */
  53401. hasMesh(mesh: AbstractMesh): boolean;
  53402. /**
  53403. * Defines whether the current material of the mesh should be use to render the effect.
  53404. * @param mesh defines the current mesh to render
  53405. */
  53406. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53407. /**
  53408. * Add a mesh to be rendered through its own material and not with emissive only.
  53409. * @param mesh The mesh for which we need to use its material
  53410. */
  53411. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53412. /**
  53413. * Remove a mesh from being rendered through its own material and not with emissive only.
  53414. * @param mesh The mesh for which we need to not use its material
  53415. */
  53416. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53417. /**
  53418. * Free any resources and references associated to a mesh.
  53419. * Internal use
  53420. * @param mesh The mesh to free.
  53421. * @hidden
  53422. */
  53423. _disposeMesh(mesh: Mesh): void;
  53424. /**
  53425. * Gets the class name of the effect layer
  53426. * @returns the string with the class name of the effect layer
  53427. */
  53428. getClassName(): string;
  53429. /**
  53430. * Serializes this glow layer
  53431. * @returns a serialized glow layer object
  53432. */
  53433. serialize(): any;
  53434. /**
  53435. * Creates a Glow Layer from parsed glow layer data
  53436. * @param parsedGlowLayer defines glow layer data
  53437. * @param scene defines the current scene
  53438. * @param rootUrl defines the root URL containing the glow layer information
  53439. * @returns a parsed Glow Layer
  53440. */
  53441. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53442. }
  53443. }
  53444. declare module BABYLON {
  53445. /** @hidden */
  53446. export var glowBlurPostProcessPixelShader: {
  53447. name: string;
  53448. shader: string;
  53449. };
  53450. }
  53451. declare module BABYLON {
  53452. interface AbstractScene {
  53453. /**
  53454. * Return a the first highlight layer of the scene with a given name.
  53455. * @param name The name of the highlight layer to look for.
  53456. * @return The highlight layer if found otherwise null.
  53457. */
  53458. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53459. }
  53460. /**
  53461. * Highlight layer options. This helps customizing the behaviour
  53462. * of the highlight layer.
  53463. */
  53464. export interface IHighlightLayerOptions {
  53465. /**
  53466. * Multiplication factor apply to the canvas size to compute the render target size
  53467. * used to generated the glowing objects (the smaller the faster).
  53468. */
  53469. mainTextureRatio: number;
  53470. /**
  53471. * Enforces a fixed size texture to ensure resize independant blur.
  53472. */
  53473. mainTextureFixedSize?: number;
  53474. /**
  53475. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53476. * of the picture to blur (the smaller the faster).
  53477. */
  53478. blurTextureSizeRatio: number;
  53479. /**
  53480. * How big in texel of the blur texture is the vertical blur.
  53481. */
  53482. blurVerticalSize: number;
  53483. /**
  53484. * How big in texel of the blur texture is the horizontal blur.
  53485. */
  53486. blurHorizontalSize: number;
  53487. /**
  53488. * Alpha blending mode used to apply the blur. Default is combine.
  53489. */
  53490. alphaBlendingMode: number;
  53491. /**
  53492. * The camera attached to the layer.
  53493. */
  53494. camera: Nullable<Camera>;
  53495. /**
  53496. * Should we display highlight as a solid stroke?
  53497. */
  53498. isStroke?: boolean;
  53499. /**
  53500. * The rendering group to draw the layer in.
  53501. */
  53502. renderingGroupId: number;
  53503. }
  53504. /**
  53505. * The highlight layer Helps adding a glow effect around a mesh.
  53506. *
  53507. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53508. * glowy meshes to your scene.
  53509. *
  53510. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53511. */
  53512. export class HighlightLayer extends EffectLayer {
  53513. name: string;
  53514. /**
  53515. * Effect Name of the highlight layer.
  53516. */
  53517. static readonly EffectName: string;
  53518. /**
  53519. * The neutral color used during the preparation of the glow effect.
  53520. * This is black by default as the blend operation is a blend operation.
  53521. */
  53522. static NeutralColor: Color4;
  53523. /**
  53524. * Stencil value used for glowing meshes.
  53525. */
  53526. static GlowingMeshStencilReference: number;
  53527. /**
  53528. * Stencil value used for the other meshes in the scene.
  53529. */
  53530. static NormalMeshStencilReference: number;
  53531. /**
  53532. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53533. */
  53534. innerGlow: boolean;
  53535. /**
  53536. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53537. */
  53538. outerGlow: boolean;
  53539. /**
  53540. * Specifies the horizontal size of the blur.
  53541. */
  53542. set blurHorizontalSize(value: number);
  53543. /**
  53544. * Specifies the vertical size of the blur.
  53545. */
  53546. set blurVerticalSize(value: number);
  53547. /**
  53548. * Gets the horizontal size of the blur.
  53549. */
  53550. get blurHorizontalSize(): number;
  53551. /**
  53552. * Gets the vertical size of the blur.
  53553. */
  53554. get blurVerticalSize(): number;
  53555. /**
  53556. * An event triggered when the highlight layer is being blurred.
  53557. */
  53558. onBeforeBlurObservable: Observable<HighlightLayer>;
  53559. /**
  53560. * An event triggered when the highlight layer has been blurred.
  53561. */
  53562. onAfterBlurObservable: Observable<HighlightLayer>;
  53563. private _instanceGlowingMeshStencilReference;
  53564. private _options;
  53565. private _downSamplePostprocess;
  53566. private _horizontalBlurPostprocess;
  53567. private _verticalBlurPostprocess;
  53568. private _blurTexture;
  53569. private _meshes;
  53570. private _excludedMeshes;
  53571. /**
  53572. * Instantiates a new highlight Layer and references it to the scene..
  53573. * @param name The name of the layer
  53574. * @param scene The scene to use the layer in
  53575. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53576. */
  53577. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53578. /**
  53579. * Get the effect name of the layer.
  53580. * @return The effect name
  53581. */
  53582. getEffectName(): string;
  53583. /**
  53584. * Create the merge effect. This is the shader use to blit the information back
  53585. * to the main canvas at the end of the scene rendering.
  53586. */
  53587. protected _createMergeEffect(): Effect;
  53588. /**
  53589. * Creates the render target textures and post processes used in the highlight layer.
  53590. */
  53591. protected _createTextureAndPostProcesses(): void;
  53592. /**
  53593. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53594. */
  53595. needStencil(): boolean;
  53596. /**
  53597. * Checks for the readiness of the element composing the layer.
  53598. * @param subMesh the mesh to check for
  53599. * @param useInstances specify wether or not to use instances to render the mesh
  53600. * @param emissiveTexture the associated emissive texture used to generate the glow
  53601. * @return true if ready otherwise, false
  53602. */
  53603. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53604. /**
  53605. * Implementation specific of rendering the generating effect on the main canvas.
  53606. * @param effect The effect used to render through
  53607. */
  53608. protected _internalRender(effect: Effect): void;
  53609. /**
  53610. * Returns true if the layer contains information to display, otherwise false.
  53611. */
  53612. shouldRender(): boolean;
  53613. /**
  53614. * Returns true if the mesh should render, otherwise false.
  53615. * @param mesh The mesh to render
  53616. * @returns true if it should render otherwise false
  53617. */
  53618. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53619. /**
  53620. * Sets the required values for both the emissive texture and and the main color.
  53621. */
  53622. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53623. /**
  53624. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53625. * @param mesh The mesh to exclude from the highlight layer
  53626. */
  53627. addExcludedMesh(mesh: Mesh): void;
  53628. /**
  53629. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53630. * @param mesh The mesh to highlight
  53631. */
  53632. removeExcludedMesh(mesh: Mesh): void;
  53633. /**
  53634. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53635. * @param mesh mesh to test
  53636. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53637. */
  53638. hasMesh(mesh: AbstractMesh): boolean;
  53639. /**
  53640. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53641. * @param mesh The mesh to highlight
  53642. * @param color The color of the highlight
  53643. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53644. */
  53645. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53646. /**
  53647. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53648. * @param mesh The mesh to highlight
  53649. */
  53650. removeMesh(mesh: Mesh): void;
  53651. /**
  53652. * Remove all the meshes currently referenced in the highlight layer
  53653. */
  53654. removeAllMeshes(): void;
  53655. /**
  53656. * Force the stencil to the normal expected value for none glowing parts
  53657. */
  53658. private _defaultStencilReference;
  53659. /**
  53660. * Free any resources and references associated to a mesh.
  53661. * Internal use
  53662. * @param mesh The mesh to free.
  53663. * @hidden
  53664. */
  53665. _disposeMesh(mesh: Mesh): void;
  53666. /**
  53667. * Dispose the highlight layer and free resources.
  53668. */
  53669. dispose(): void;
  53670. /**
  53671. * Gets the class name of the effect layer
  53672. * @returns the string with the class name of the effect layer
  53673. */
  53674. getClassName(): string;
  53675. /**
  53676. * Serializes this Highlight layer
  53677. * @returns a serialized Highlight layer object
  53678. */
  53679. serialize(): any;
  53680. /**
  53681. * Creates a Highlight layer from parsed Highlight layer data
  53682. * @param parsedHightlightLayer defines the Highlight layer data
  53683. * @param scene defines the current scene
  53684. * @param rootUrl defines the root URL containing the Highlight layer information
  53685. * @returns a parsed Highlight layer
  53686. */
  53687. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53688. }
  53689. }
  53690. declare module BABYLON {
  53691. interface AbstractScene {
  53692. /**
  53693. * The list of layers (background and foreground) of the scene
  53694. */
  53695. layers: Array<Layer>;
  53696. }
  53697. /**
  53698. * Defines the layer scene component responsible to manage any layers
  53699. * in a given scene.
  53700. */
  53701. export class LayerSceneComponent implements ISceneComponent {
  53702. /**
  53703. * The component name helpfull to identify the component in the list of scene components.
  53704. */
  53705. readonly name: string;
  53706. /**
  53707. * The scene the component belongs to.
  53708. */
  53709. scene: Scene;
  53710. private _engine;
  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. * Disposes the component and the associated ressources.
  53727. */
  53728. dispose(): void;
  53729. private _draw;
  53730. private _drawCameraPredicate;
  53731. private _drawCameraBackground;
  53732. private _drawCameraForeground;
  53733. private _drawRenderTargetPredicate;
  53734. private _drawRenderTargetBackground;
  53735. private _drawRenderTargetForeground;
  53736. /**
  53737. * Adds all the elements from the container to the scene
  53738. * @param container the container holding the elements
  53739. */
  53740. addFromContainer(container: AbstractScene): void;
  53741. /**
  53742. * Removes all the elements in the container from the scene
  53743. * @param container contains the elements to remove
  53744. * @param dispose if the removed element should be disposed (default: false)
  53745. */
  53746. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53747. }
  53748. }
  53749. declare module BABYLON {
  53750. /** @hidden */
  53751. export var layerPixelShader: {
  53752. name: string;
  53753. shader: string;
  53754. };
  53755. }
  53756. declare module BABYLON {
  53757. /** @hidden */
  53758. export var layerVertexShader: {
  53759. name: string;
  53760. shader: string;
  53761. };
  53762. }
  53763. declare module BABYLON {
  53764. /**
  53765. * This represents a full screen 2d layer.
  53766. * This can be useful to display a picture in the background of your scene for instance.
  53767. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53768. */
  53769. export class Layer {
  53770. /**
  53771. * Define the name of the layer.
  53772. */
  53773. name: string;
  53774. /**
  53775. * Define the texture the layer should display.
  53776. */
  53777. texture: Nullable<Texture>;
  53778. /**
  53779. * Is the layer in background or foreground.
  53780. */
  53781. isBackground: boolean;
  53782. /**
  53783. * Define the color of the layer (instead of texture).
  53784. */
  53785. color: Color4;
  53786. /**
  53787. * Define the scale of the layer in order to zoom in out of the texture.
  53788. */
  53789. scale: Vector2;
  53790. /**
  53791. * Define an offset for the layer in order to shift the texture.
  53792. */
  53793. offset: Vector2;
  53794. /**
  53795. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53796. */
  53797. alphaBlendingMode: number;
  53798. /**
  53799. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53800. * Alpha test will not mix with the background color in case of transparency.
  53801. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53802. */
  53803. alphaTest: boolean;
  53804. /**
  53805. * Define a mask to restrict the layer to only some of the scene cameras.
  53806. */
  53807. layerMask: number;
  53808. /**
  53809. * Define the list of render target the layer is visible into.
  53810. */
  53811. renderTargetTextures: RenderTargetTexture[];
  53812. /**
  53813. * Define if the layer is only used in renderTarget or if it also
  53814. * renders in the main frame buffer of the canvas.
  53815. */
  53816. renderOnlyInRenderTargetTextures: boolean;
  53817. private _scene;
  53818. private _vertexBuffers;
  53819. private _indexBuffer;
  53820. private _effect;
  53821. private _previousDefines;
  53822. /**
  53823. * An event triggered when the layer is disposed.
  53824. */
  53825. onDisposeObservable: Observable<Layer>;
  53826. private _onDisposeObserver;
  53827. /**
  53828. * Back compatibility with callback before the onDisposeObservable existed.
  53829. * The set callback will be triggered when the layer has been disposed.
  53830. */
  53831. set onDispose(callback: () => void);
  53832. /**
  53833. * An event triggered before rendering the scene
  53834. */
  53835. onBeforeRenderObservable: Observable<Layer>;
  53836. private _onBeforeRenderObserver;
  53837. /**
  53838. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53839. * The set callback will be triggered just before rendering the layer.
  53840. */
  53841. set onBeforeRender(callback: () => void);
  53842. /**
  53843. * An event triggered after rendering the scene
  53844. */
  53845. onAfterRenderObservable: Observable<Layer>;
  53846. private _onAfterRenderObserver;
  53847. /**
  53848. * Back compatibility with callback before the onAfterRenderObservable existed.
  53849. * The set callback will be triggered just after rendering the layer.
  53850. */
  53851. set onAfterRender(callback: () => void);
  53852. /**
  53853. * Instantiates a new layer.
  53854. * This represents a full screen 2d layer.
  53855. * This can be useful to display a picture in the background of your scene for instance.
  53856. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53857. * @param name Define the name of the layer in the scene
  53858. * @param imgUrl Define the url of the texture to display in the layer
  53859. * @param scene Define the scene the layer belongs to
  53860. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53861. * @param color Defines a color for the layer
  53862. */
  53863. constructor(
  53864. /**
  53865. * Define the name of the layer.
  53866. */
  53867. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53868. private _createIndexBuffer;
  53869. /** @hidden */
  53870. _rebuild(): void;
  53871. /**
  53872. * Renders the layer in the scene.
  53873. */
  53874. render(): void;
  53875. /**
  53876. * Disposes and releases the associated ressources.
  53877. */
  53878. dispose(): void;
  53879. }
  53880. }
  53881. declare module BABYLON {
  53882. /** @hidden */
  53883. export var lensFlarePixelShader: {
  53884. name: string;
  53885. shader: string;
  53886. };
  53887. }
  53888. declare module BABYLON {
  53889. /** @hidden */
  53890. export var lensFlareVertexShader: {
  53891. name: string;
  53892. shader: string;
  53893. };
  53894. }
  53895. declare module BABYLON {
  53896. /**
  53897. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53898. * It is usually composed of several `lensFlare`.
  53899. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53900. */
  53901. export class LensFlareSystem {
  53902. /**
  53903. * Define the name of the lens flare system
  53904. */
  53905. name: string;
  53906. /**
  53907. * List of lens flares used in this system.
  53908. */
  53909. lensFlares: LensFlare[];
  53910. /**
  53911. * Define a limit from the border the lens flare can be visible.
  53912. */
  53913. borderLimit: number;
  53914. /**
  53915. * Define a viewport border we do not want to see the lens flare in.
  53916. */
  53917. viewportBorder: number;
  53918. /**
  53919. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53920. */
  53921. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53922. /**
  53923. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53924. */
  53925. layerMask: number;
  53926. /**
  53927. * Define the id of the lens flare system in the scene.
  53928. * (equal to name by default)
  53929. */
  53930. id: string;
  53931. private _scene;
  53932. private _emitter;
  53933. private _vertexBuffers;
  53934. private _indexBuffer;
  53935. private _effect;
  53936. private _positionX;
  53937. private _positionY;
  53938. private _isEnabled;
  53939. /** @hidden */
  53940. static _SceneComponentInitialization: (scene: Scene) => void;
  53941. /**
  53942. * Instantiates a lens flare system.
  53943. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53944. * It is usually composed of several `lensFlare`.
  53945. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53946. * @param name Define the name of the lens flare system in the scene
  53947. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53948. * @param scene Define the scene the lens flare system belongs to
  53949. */
  53950. constructor(
  53951. /**
  53952. * Define the name of the lens flare system
  53953. */
  53954. name: string, emitter: any, scene: Scene);
  53955. /**
  53956. * Define if the lens flare system is enabled.
  53957. */
  53958. get isEnabled(): boolean;
  53959. set isEnabled(value: boolean);
  53960. /**
  53961. * Get the scene the effects belongs to.
  53962. * @returns the scene holding the lens flare system
  53963. */
  53964. getScene(): Scene;
  53965. /**
  53966. * Get the emitter of the lens flare system.
  53967. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53968. * @returns the emitter of the lens flare system
  53969. */
  53970. getEmitter(): any;
  53971. /**
  53972. * Set the emitter of the lens flare system.
  53973. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53974. * @param newEmitter Define the new emitter of the system
  53975. */
  53976. setEmitter(newEmitter: any): void;
  53977. /**
  53978. * Get the lens flare system emitter position.
  53979. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53980. * @returns the position
  53981. */
  53982. getEmitterPosition(): Vector3;
  53983. /**
  53984. * @hidden
  53985. */
  53986. computeEffectivePosition(globalViewport: Viewport): boolean;
  53987. /** @hidden */
  53988. _isVisible(): boolean;
  53989. /**
  53990. * @hidden
  53991. */
  53992. render(): boolean;
  53993. /**
  53994. * Dispose and release the lens flare with its associated resources.
  53995. */
  53996. dispose(): void;
  53997. /**
  53998. * Parse a lens flare system from a JSON repressentation
  53999. * @param parsedLensFlareSystem Define the JSON to parse
  54000. * @param scene Define the scene the parsed system should be instantiated in
  54001. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54002. * @returns the parsed system
  54003. */
  54004. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54005. /**
  54006. * Serialize the current Lens Flare System into a JSON representation.
  54007. * @returns the serialized JSON
  54008. */
  54009. serialize(): any;
  54010. }
  54011. }
  54012. declare module BABYLON {
  54013. /**
  54014. * This represents one of the lens effect in a `lensFlareSystem`.
  54015. * It controls one of the indiviual texture used in the effect.
  54016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54017. */
  54018. export class LensFlare {
  54019. /**
  54020. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54021. */
  54022. size: number;
  54023. /**
  54024. * 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.
  54025. */
  54026. position: number;
  54027. /**
  54028. * Define the lens color.
  54029. */
  54030. color: Color3;
  54031. /**
  54032. * Define the lens texture.
  54033. */
  54034. texture: Nullable<Texture>;
  54035. /**
  54036. * Define the alpha mode to render this particular lens.
  54037. */
  54038. alphaMode: number;
  54039. private _system;
  54040. /**
  54041. * Creates a new Lens Flare.
  54042. * This represents one of the lens effect in a `lensFlareSystem`.
  54043. * It controls one of the indiviual texture used in the effect.
  54044. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54045. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54046. * @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.
  54047. * @param color Define the lens color
  54048. * @param imgUrl Define the lens texture url
  54049. * @param system Define the `lensFlareSystem` this flare is part of
  54050. * @returns The newly created Lens Flare
  54051. */
  54052. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54053. /**
  54054. * Instantiates a new Lens Flare.
  54055. * This represents one of the lens effect in a `lensFlareSystem`.
  54056. * It controls one of the indiviual texture used in the effect.
  54057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54058. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54059. * @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.
  54060. * @param color Define the lens color
  54061. * @param imgUrl Define the lens texture url
  54062. * @param system Define the `lensFlareSystem` this flare is part of
  54063. */
  54064. constructor(
  54065. /**
  54066. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54067. */
  54068. size: number,
  54069. /**
  54070. * 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.
  54071. */
  54072. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54073. /**
  54074. * Dispose and release the lens flare with its associated resources.
  54075. */
  54076. dispose(): void;
  54077. }
  54078. }
  54079. declare module BABYLON {
  54080. interface AbstractScene {
  54081. /**
  54082. * The list of lens flare system added to the scene
  54083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54084. */
  54085. lensFlareSystems: Array<LensFlareSystem>;
  54086. /**
  54087. * Removes the given lens flare system from this scene.
  54088. * @param toRemove The lens flare system to remove
  54089. * @returns The index of the removed lens flare system
  54090. */
  54091. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54092. /**
  54093. * Adds the given lens flare system to this scene
  54094. * @param newLensFlareSystem The lens flare system to add
  54095. */
  54096. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54097. /**
  54098. * Gets a lens flare system using its name
  54099. * @param name defines the name to look for
  54100. * @returns the lens flare system or null if not found
  54101. */
  54102. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54103. /**
  54104. * Gets a lens flare system using its id
  54105. * @param id defines the id to look for
  54106. * @returns the lens flare system or null if not found
  54107. */
  54108. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54109. }
  54110. /**
  54111. * Defines the lens flare scene component responsible to manage any lens flares
  54112. * in a given scene.
  54113. */
  54114. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54115. /**
  54116. * The component name helpfull to identify the component in the list of scene components.
  54117. */
  54118. readonly name: string;
  54119. /**
  54120. * The scene the component belongs to.
  54121. */
  54122. scene: Scene;
  54123. /**
  54124. * Creates a new instance of the component for the given scene
  54125. * @param scene Defines the scene to register the component in
  54126. */
  54127. constructor(scene: Scene);
  54128. /**
  54129. * Registers the component in a given scene
  54130. */
  54131. register(): void;
  54132. /**
  54133. * Rebuilds the elements related to this component in case of
  54134. * context lost for instance.
  54135. */
  54136. rebuild(): void;
  54137. /**
  54138. * Adds all the elements from the container to the scene
  54139. * @param container the container holding the elements
  54140. */
  54141. addFromContainer(container: AbstractScene): void;
  54142. /**
  54143. * Removes all the elements in the container from the scene
  54144. * @param container contains the elements to remove
  54145. * @param dispose if the removed element should be disposed (default: false)
  54146. */
  54147. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54148. /**
  54149. * Serializes the component data to the specified json object
  54150. * @param serializationObject The object to serialize to
  54151. */
  54152. serialize(serializationObject: any): void;
  54153. /**
  54154. * Disposes the component and the associated ressources.
  54155. */
  54156. dispose(): void;
  54157. private _draw;
  54158. }
  54159. }
  54160. declare module BABYLON {
  54161. /** @hidden */
  54162. export var depthPixelShader: {
  54163. name: string;
  54164. shader: string;
  54165. };
  54166. }
  54167. declare module BABYLON {
  54168. /** @hidden */
  54169. export var depthVertexShader: {
  54170. name: string;
  54171. shader: string;
  54172. };
  54173. }
  54174. declare module BABYLON {
  54175. /**
  54176. * This represents a depth renderer in Babylon.
  54177. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54178. */
  54179. export class DepthRenderer {
  54180. private _scene;
  54181. private _depthMap;
  54182. private _effect;
  54183. private readonly _storeNonLinearDepth;
  54184. private readonly _clearColor;
  54185. /** Get if the depth renderer is using packed depth or not */
  54186. readonly isPacked: boolean;
  54187. private _cachedDefines;
  54188. private _camera;
  54189. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54190. enabled: boolean;
  54191. /**
  54192. * Specifiess that the depth renderer will only be used within
  54193. * the camera it is created for.
  54194. * This can help forcing its rendering during the camera processing.
  54195. */
  54196. useOnlyInActiveCamera: boolean;
  54197. /** @hidden */
  54198. static _SceneComponentInitialization: (scene: Scene) => void;
  54199. /**
  54200. * Instantiates a depth renderer
  54201. * @param scene The scene the renderer belongs to
  54202. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54203. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54204. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54205. */
  54206. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54207. /**
  54208. * Creates the depth rendering effect and checks if the effect is ready.
  54209. * @param subMesh The submesh to be used to render the depth map of
  54210. * @param useInstances If multiple world instances should be used
  54211. * @returns if the depth renderer is ready to render the depth map
  54212. */
  54213. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54214. /**
  54215. * Gets the texture which the depth map will be written to.
  54216. * @returns The depth map texture
  54217. */
  54218. getDepthMap(): RenderTargetTexture;
  54219. /**
  54220. * Disposes of the depth renderer.
  54221. */
  54222. dispose(): void;
  54223. }
  54224. }
  54225. declare module BABYLON {
  54226. /** @hidden */
  54227. export var minmaxReduxPixelShader: {
  54228. name: string;
  54229. shader: string;
  54230. };
  54231. }
  54232. declare module BABYLON {
  54233. /**
  54234. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54235. * and maximum values from all values of the texture.
  54236. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54237. * The source values are read from the red channel of the texture.
  54238. */
  54239. export class MinMaxReducer {
  54240. /**
  54241. * Observable triggered when the computation has been performed
  54242. */
  54243. onAfterReductionPerformed: Observable<{
  54244. min: number;
  54245. max: number;
  54246. }>;
  54247. protected _camera: Camera;
  54248. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54249. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54250. protected _postProcessManager: PostProcessManager;
  54251. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54252. protected _forceFullscreenViewport: boolean;
  54253. /**
  54254. * Creates a min/max reducer
  54255. * @param camera The camera to use for the post processes
  54256. */
  54257. constructor(camera: Camera);
  54258. /**
  54259. * Gets the texture used to read the values from.
  54260. */
  54261. get sourceTexture(): Nullable<RenderTargetTexture>;
  54262. /**
  54263. * Sets the source texture to read the values from.
  54264. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54265. * because in such textures '1' value must not be taken into account to compute the maximum
  54266. * as this value is used to clear the texture.
  54267. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54268. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54269. * @param depthRedux Indicates if the texture is a depth texture or not
  54270. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54271. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54272. */
  54273. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54274. /**
  54275. * Defines the refresh rate of the computation.
  54276. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54277. */
  54278. get refreshRate(): number;
  54279. set refreshRate(value: number);
  54280. protected _activated: boolean;
  54281. /**
  54282. * Gets the activation status of the reducer
  54283. */
  54284. get activated(): boolean;
  54285. /**
  54286. * Activates the reduction computation.
  54287. * When activated, the observers registered in onAfterReductionPerformed are
  54288. * called after the compuation is performed
  54289. */
  54290. activate(): void;
  54291. /**
  54292. * Deactivates the reduction computation.
  54293. */
  54294. deactivate(): void;
  54295. /**
  54296. * Disposes the min/max reducer
  54297. * @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.
  54298. */
  54299. dispose(disposeAll?: boolean): void;
  54300. }
  54301. }
  54302. declare module BABYLON {
  54303. /**
  54304. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54305. */
  54306. export class DepthReducer extends MinMaxReducer {
  54307. private _depthRenderer;
  54308. private _depthRendererId;
  54309. /**
  54310. * Gets the depth renderer used for the computation.
  54311. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54312. */
  54313. get depthRenderer(): Nullable<DepthRenderer>;
  54314. /**
  54315. * Creates a depth reducer
  54316. * @param camera The camera used to render the depth texture
  54317. */
  54318. constructor(camera: Camera);
  54319. /**
  54320. * Sets the depth renderer to use to generate the depth map
  54321. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54322. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54323. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54324. */
  54325. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54326. /** @hidden */
  54327. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54328. /**
  54329. * Activates the reduction computation.
  54330. * When activated, the observers registered in onAfterReductionPerformed are
  54331. * called after the compuation is performed
  54332. */
  54333. activate(): void;
  54334. /**
  54335. * Deactivates the reduction computation.
  54336. */
  54337. deactivate(): void;
  54338. /**
  54339. * Disposes the depth reducer
  54340. * @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.
  54341. */
  54342. dispose(disposeAll?: boolean): void;
  54343. }
  54344. }
  54345. declare module BABYLON {
  54346. /**
  54347. * A CSM implementation allowing casting shadows on large scenes.
  54348. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54349. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54350. */
  54351. export class CascadedShadowGenerator extends ShadowGenerator {
  54352. private static readonly frustumCornersNDCSpace;
  54353. /**
  54354. * Name of the CSM class
  54355. */
  54356. static CLASSNAME: string;
  54357. /**
  54358. * Defines the default number of cascades used by the CSM.
  54359. */
  54360. static readonly DEFAULT_CASCADES_COUNT: number;
  54361. /**
  54362. * Defines the minimum number of cascades used by the CSM.
  54363. */
  54364. static readonly MIN_CASCADES_COUNT: number;
  54365. /**
  54366. * Defines the maximum number of cascades used by the CSM.
  54367. */
  54368. static readonly MAX_CASCADES_COUNT: number;
  54369. protected _validateFilter(filter: number): number;
  54370. /**
  54371. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54372. */
  54373. penumbraDarkness: number;
  54374. private _numCascades;
  54375. /**
  54376. * Gets or set the number of cascades used by the CSM.
  54377. */
  54378. get numCascades(): number;
  54379. set numCascades(value: number);
  54380. /**
  54381. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54382. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54383. */
  54384. stabilizeCascades: boolean;
  54385. private _freezeShadowCastersBoundingInfo;
  54386. private _freezeShadowCastersBoundingInfoObservable;
  54387. /**
  54388. * Enables or disables the shadow casters bounding info computation.
  54389. * If your shadow casters don't move, you can disable this feature.
  54390. * If it is enabled, the bounding box computation is done every frame.
  54391. */
  54392. get freezeShadowCastersBoundingInfo(): boolean;
  54393. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54394. private _scbiMin;
  54395. private _scbiMax;
  54396. protected _computeShadowCastersBoundingInfo(): void;
  54397. protected _shadowCastersBoundingInfo: BoundingInfo;
  54398. /**
  54399. * Gets or sets the shadow casters bounding info.
  54400. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54401. * so that the system won't overwrite the bounds you provide
  54402. */
  54403. get shadowCastersBoundingInfo(): BoundingInfo;
  54404. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54405. protected _breaksAreDirty: boolean;
  54406. protected _minDistance: number;
  54407. protected _maxDistance: number;
  54408. /**
  54409. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54410. *
  54411. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54412. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54413. * @param min minimal distance for the breaks (default to 0.)
  54414. * @param max maximal distance for the breaks (default to 1.)
  54415. */
  54416. setMinMaxDistance(min: number, max: number): void;
  54417. /** Gets the minimal distance used in the cascade break computation */
  54418. get minDistance(): number;
  54419. /** Gets the maximal distance used in the cascade break computation */
  54420. get maxDistance(): number;
  54421. /**
  54422. * Gets the class name of that object
  54423. * @returns "CascadedShadowGenerator"
  54424. */
  54425. getClassName(): string;
  54426. private _cascadeMinExtents;
  54427. private _cascadeMaxExtents;
  54428. /**
  54429. * Gets a cascade minimum extents
  54430. * @param cascadeIndex index of the cascade
  54431. * @returns the minimum cascade extents
  54432. */
  54433. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54434. /**
  54435. * Gets a cascade maximum extents
  54436. * @param cascadeIndex index of the cascade
  54437. * @returns the maximum cascade extents
  54438. */
  54439. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54440. private _cascades;
  54441. private _currentLayer;
  54442. private _viewSpaceFrustumsZ;
  54443. private _viewMatrices;
  54444. private _projectionMatrices;
  54445. private _transformMatrices;
  54446. private _transformMatricesAsArray;
  54447. private _frustumLengths;
  54448. private _lightSizeUVCorrection;
  54449. private _depthCorrection;
  54450. private _frustumCornersWorldSpace;
  54451. private _frustumCenter;
  54452. private _shadowCameraPos;
  54453. private _shadowMaxZ;
  54454. /**
  54455. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54456. * It defaults to camera.maxZ
  54457. */
  54458. get shadowMaxZ(): number;
  54459. /**
  54460. * Sets the shadow max z distance.
  54461. */
  54462. set shadowMaxZ(value: number);
  54463. protected _debug: boolean;
  54464. /**
  54465. * Gets or sets the debug flag.
  54466. * When enabled, the cascades are materialized by different colors on the screen.
  54467. */
  54468. get debug(): boolean;
  54469. set debug(dbg: boolean);
  54470. private _depthClamp;
  54471. /**
  54472. * Gets or sets the depth clamping value.
  54473. *
  54474. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54475. * to account for the shadow casters far away.
  54476. *
  54477. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54478. */
  54479. get depthClamp(): boolean;
  54480. set depthClamp(value: boolean);
  54481. private _cascadeBlendPercentage;
  54482. /**
  54483. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54484. * It defaults to 0.1 (10% blending).
  54485. */
  54486. get cascadeBlendPercentage(): number;
  54487. set cascadeBlendPercentage(value: number);
  54488. private _lambda;
  54489. /**
  54490. * Gets or set the lambda parameter.
  54491. * This parameter is used to split the camera frustum and create the cascades.
  54492. * 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.
  54493. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54494. */
  54495. get lambda(): number;
  54496. set lambda(value: number);
  54497. /**
  54498. * Gets the view matrix corresponding to a given cascade
  54499. * @param cascadeNum cascade to retrieve the view matrix from
  54500. * @returns the cascade view matrix
  54501. */
  54502. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54503. /**
  54504. * Gets the projection matrix corresponding to a given cascade
  54505. * @param cascadeNum cascade to retrieve the projection matrix from
  54506. * @returns the cascade projection matrix
  54507. */
  54508. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54509. /**
  54510. * Gets the transformation matrix corresponding to a given cascade
  54511. * @param cascadeNum cascade to retrieve the transformation matrix from
  54512. * @returns the cascade transformation matrix
  54513. */
  54514. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54515. private _depthRenderer;
  54516. /**
  54517. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54518. *
  54519. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54520. *
  54521. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54522. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54523. * @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
  54524. */
  54525. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54526. private _depthReducer;
  54527. private _autoCalcDepthBounds;
  54528. /**
  54529. * Gets or sets the autoCalcDepthBounds property.
  54530. *
  54531. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54532. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54533. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54534. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54535. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54536. */
  54537. get autoCalcDepthBounds(): boolean;
  54538. set autoCalcDepthBounds(value: boolean);
  54539. /**
  54540. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54541. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54542. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54543. * for setting the refresh rate on the renderer yourself!
  54544. */
  54545. get autoCalcDepthBoundsRefreshRate(): number;
  54546. set autoCalcDepthBoundsRefreshRate(value: number);
  54547. /**
  54548. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54549. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54550. * you change the camera near/far planes!
  54551. */
  54552. splitFrustum(): void;
  54553. private _splitFrustum;
  54554. private _computeMatrices;
  54555. private _computeFrustumInWorldSpace;
  54556. private _computeCascadeFrustum;
  54557. /** @hidden */
  54558. static _SceneComponentInitialization: (scene: Scene) => void;
  54559. /**
  54560. * Creates a Cascaded Shadow Generator object.
  54561. * A ShadowGenerator is the required tool to use the shadows.
  54562. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54563. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54564. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54565. * @param light The directional light object generating the shadows.
  54566. * @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.
  54567. */
  54568. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54569. protected _initializeGenerator(): void;
  54570. protected _createTargetRenderTexture(): void;
  54571. protected _initializeShadowMap(): void;
  54572. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54573. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54574. /**
  54575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54576. * @param defines Defines of the material we want to update
  54577. * @param lightIndex Index of the light in the enabled light list of the material
  54578. */
  54579. prepareDefines(defines: any, lightIndex: number): void;
  54580. /**
  54581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54582. * defined in the generator but impacting the effect).
  54583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54584. * @param effect The effect we are binfing the information for
  54585. */
  54586. bindShadowLight(lightIndex: string, effect: Effect): void;
  54587. /**
  54588. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54589. * (eq to view projection * shadow projection matrices)
  54590. * @returns The transform matrix used to create the shadow map
  54591. */
  54592. getTransformMatrix(): Matrix;
  54593. /**
  54594. * Disposes the ShadowGenerator.
  54595. * Returns nothing.
  54596. */
  54597. dispose(): void;
  54598. /**
  54599. * Serializes the shadow generator setup to a json object.
  54600. * @returns The serialized JSON object
  54601. */
  54602. serialize(): any;
  54603. /**
  54604. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54605. * @param parsedShadowGenerator The JSON object to parse
  54606. * @param scene The scene to create the shadow map for
  54607. * @returns The parsed shadow generator
  54608. */
  54609. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54610. }
  54611. }
  54612. declare module BABYLON {
  54613. /**
  54614. * Defines the shadow generator component responsible to manage any shadow generators
  54615. * in a given scene.
  54616. */
  54617. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54618. /**
  54619. * The component name helpfull to identify the component in the list of scene components.
  54620. */
  54621. readonly name: string;
  54622. /**
  54623. * The scene the component belongs to.
  54624. */
  54625. scene: Scene;
  54626. /**
  54627. * Creates a new instance of the component for the given scene
  54628. * @param scene Defines the scene to register the component in
  54629. */
  54630. constructor(scene: Scene);
  54631. /**
  54632. * Registers the component in a given scene
  54633. */
  54634. register(): void;
  54635. /**
  54636. * Rebuilds the elements related to this component in case of
  54637. * context lost for instance.
  54638. */
  54639. rebuild(): void;
  54640. /**
  54641. * Serializes the component data to the specified json object
  54642. * @param serializationObject The object to serialize to
  54643. */
  54644. serialize(serializationObject: any): void;
  54645. /**
  54646. * Adds all the elements from the container to the scene
  54647. * @param container the container holding the elements
  54648. */
  54649. addFromContainer(container: AbstractScene): void;
  54650. /**
  54651. * Removes all the elements in the container from the scene
  54652. * @param container contains the elements to remove
  54653. * @param dispose if the removed element should be disposed (default: false)
  54654. */
  54655. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54656. /**
  54657. * Rebuilds the elements related to this component in case of
  54658. * context lost for instance.
  54659. */
  54660. dispose(): void;
  54661. private _gatherRenderTargets;
  54662. }
  54663. }
  54664. declare module BABYLON {
  54665. /**
  54666. * A point light is a light defined by an unique point in world space.
  54667. * The light is emitted in every direction from this point.
  54668. * A good example of a point light is a standard light bulb.
  54669. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54670. */
  54671. export class PointLight extends ShadowLight {
  54672. private _shadowAngle;
  54673. /**
  54674. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54675. * This specifies what angle the shadow will use to be created.
  54676. *
  54677. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54678. */
  54679. get shadowAngle(): number;
  54680. /**
  54681. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54682. * This specifies what angle the shadow will use to be created.
  54683. *
  54684. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54685. */
  54686. set shadowAngle(value: number);
  54687. /**
  54688. * Gets the direction if it has been set.
  54689. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54690. */
  54691. get direction(): Vector3;
  54692. /**
  54693. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54694. */
  54695. set direction(value: Vector3);
  54696. /**
  54697. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54698. * A PointLight emits the light in every direction.
  54699. * It can cast shadows.
  54700. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54701. * ```javascript
  54702. * var pointLight = new PointLight("pl", camera.position, scene);
  54703. * ```
  54704. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54705. * @param name The light friendly name
  54706. * @param position The position of the point light in the scene
  54707. * @param scene The scene the lights belongs to
  54708. */
  54709. constructor(name: string, position: Vector3, scene: Scene);
  54710. /**
  54711. * Returns the string "PointLight"
  54712. * @returns the class name
  54713. */
  54714. getClassName(): string;
  54715. /**
  54716. * Returns the integer 0.
  54717. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54718. */
  54719. getTypeID(): number;
  54720. /**
  54721. * Specifies wether or not the shadowmap should be a cube texture.
  54722. * @returns true if the shadowmap needs to be a cube texture.
  54723. */
  54724. needCube(): boolean;
  54725. /**
  54726. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54727. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54728. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54729. */
  54730. getShadowDirection(faceIndex?: number): Vector3;
  54731. /**
  54732. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54733. * - fov = PI / 2
  54734. * - aspect ratio : 1.0
  54735. * - z-near and far equal to the active camera minZ and maxZ.
  54736. * Returns the PointLight.
  54737. */
  54738. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54739. protected _buildUniformLayout(): void;
  54740. /**
  54741. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54742. * @param effect The effect to update
  54743. * @param lightIndex The index of the light in the effect to update
  54744. * @returns The point light
  54745. */
  54746. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54747. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54748. /**
  54749. * Prepares the list of defines specific to the light type.
  54750. * @param defines the list of defines
  54751. * @param lightIndex defines the index of the light for the effect
  54752. */
  54753. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54754. }
  54755. }
  54756. declare module BABYLON {
  54757. /**
  54758. * Header information of HDR texture files.
  54759. */
  54760. export interface HDRInfo {
  54761. /**
  54762. * The height of the texture in pixels.
  54763. */
  54764. height: number;
  54765. /**
  54766. * The width of the texture in pixels.
  54767. */
  54768. width: number;
  54769. /**
  54770. * The index of the beginning of the data in the binary file.
  54771. */
  54772. dataPosition: number;
  54773. }
  54774. /**
  54775. * This groups tools to convert HDR texture to native colors array.
  54776. */
  54777. export class HDRTools {
  54778. private static Ldexp;
  54779. private static Rgbe2float;
  54780. private static readStringLine;
  54781. /**
  54782. * Reads header information from an RGBE texture stored in a native array.
  54783. * More information on this format are available here:
  54784. * https://en.wikipedia.org/wiki/RGBE_image_format
  54785. *
  54786. * @param uint8array The binary file stored in native array.
  54787. * @return The header information.
  54788. */
  54789. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54790. /**
  54791. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54792. * This RGBE texture needs to store the information as a panorama.
  54793. *
  54794. * More information on this format are available here:
  54795. * https://en.wikipedia.org/wiki/RGBE_image_format
  54796. *
  54797. * @param buffer The binary file stored in an array buffer.
  54798. * @param size The expected size of the extracted cubemap.
  54799. * @return The Cube Map information.
  54800. */
  54801. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54802. /**
  54803. * Returns the pixels data extracted from an RGBE texture.
  54804. * This pixels will be stored left to right up to down in the R G B order in one array.
  54805. *
  54806. * More information on this format are available here:
  54807. * https://en.wikipedia.org/wiki/RGBE_image_format
  54808. *
  54809. * @param uint8array The binary file stored in an array buffer.
  54810. * @param hdrInfo The header information of the file.
  54811. * @return The pixels data in RGB right to left up to down order.
  54812. */
  54813. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54814. private static RGBE_ReadPixels_RLE;
  54815. }
  54816. }
  54817. declare module BABYLON {
  54818. /**
  54819. * This represents a texture coming from an HDR input.
  54820. *
  54821. * The only supported format is currently panorama picture stored in RGBE format.
  54822. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54823. */
  54824. export class HDRCubeTexture extends BaseTexture {
  54825. private static _facesMapping;
  54826. private _generateHarmonics;
  54827. private _noMipmap;
  54828. private _textureMatrix;
  54829. private _size;
  54830. private _onLoad;
  54831. private _onError;
  54832. /**
  54833. * The texture URL.
  54834. */
  54835. url: string;
  54836. /**
  54837. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54838. */
  54839. coordinatesMode: number;
  54840. protected _isBlocking: boolean;
  54841. /**
  54842. * Sets wether or not the texture is blocking during loading.
  54843. */
  54844. set isBlocking(value: boolean);
  54845. /**
  54846. * Gets wether or not the texture is blocking during loading.
  54847. */
  54848. get isBlocking(): boolean;
  54849. protected _rotationY: number;
  54850. /**
  54851. * Sets texture matrix rotation angle around Y axis in radians.
  54852. */
  54853. set rotationY(value: number);
  54854. /**
  54855. * Gets texture matrix rotation angle around Y axis radians.
  54856. */
  54857. get rotationY(): number;
  54858. /**
  54859. * Gets or sets the center of the bounding box associated with the cube texture
  54860. * It must define where the camera used to render the texture was set
  54861. */
  54862. boundingBoxPosition: Vector3;
  54863. private _boundingBoxSize;
  54864. /**
  54865. * Gets or sets the size of the bounding box associated with the cube texture
  54866. * When defined, the cubemap will switch to local mode
  54867. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54868. * @example https://www.babylonjs-playground.com/#RNASML
  54869. */
  54870. set boundingBoxSize(value: Vector3);
  54871. get boundingBoxSize(): Vector3;
  54872. /**
  54873. * Instantiates an HDRTexture from the following parameters.
  54874. *
  54875. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54876. * @param scene The scene the texture will be used in
  54877. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54878. * @param noMipmap Forces to not generate the mipmap if true
  54879. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54880. * @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)
  54881. * @param reserved Reserved flag for internal use.
  54882. */
  54883. 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>);
  54884. /**
  54885. * Get the current class name of the texture useful for serialization or dynamic coding.
  54886. * @returns "HDRCubeTexture"
  54887. */
  54888. getClassName(): string;
  54889. /**
  54890. * Occurs when the file is raw .hdr file.
  54891. */
  54892. private loadTexture;
  54893. clone(): HDRCubeTexture;
  54894. delayLoad(): void;
  54895. /**
  54896. * Get the texture reflection matrix used to rotate/transform the reflection.
  54897. * @returns the reflection matrix
  54898. */
  54899. getReflectionTextureMatrix(): Matrix;
  54900. /**
  54901. * Set the texture reflection matrix used to rotate/transform the reflection.
  54902. * @param value Define the reflection matrix to set
  54903. */
  54904. setReflectionTextureMatrix(value: Matrix): void;
  54905. /**
  54906. * Parses a JSON representation of an HDR Texture in order to create the texture
  54907. * @param parsedTexture Define the JSON representation
  54908. * @param scene Define the scene the texture should be created in
  54909. * @param rootUrl Define the root url in case we need to load relative dependencies
  54910. * @returns the newly created texture after parsing
  54911. */
  54912. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54913. serialize(): any;
  54914. }
  54915. }
  54916. declare module BABYLON {
  54917. /**
  54918. * Class used to control physics engine
  54919. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54920. */
  54921. export class PhysicsEngine implements IPhysicsEngine {
  54922. private _physicsPlugin;
  54923. /**
  54924. * Global value used to control the smallest number supported by the simulation
  54925. */
  54926. static Epsilon: number;
  54927. private _impostors;
  54928. private _joints;
  54929. private _subTimeStep;
  54930. /**
  54931. * Gets the gravity vector used by the simulation
  54932. */
  54933. gravity: Vector3;
  54934. /**
  54935. * Factory used to create the default physics plugin.
  54936. * @returns The default physics plugin
  54937. */
  54938. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54939. /**
  54940. * Creates a new Physics Engine
  54941. * @param gravity defines the gravity vector used by the simulation
  54942. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54943. */
  54944. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54945. /**
  54946. * Sets the gravity vector used by the simulation
  54947. * @param gravity defines the gravity vector to use
  54948. */
  54949. setGravity(gravity: Vector3): void;
  54950. /**
  54951. * Set the time step of the physics engine.
  54952. * Default is 1/60.
  54953. * To slow it down, enter 1/600 for example.
  54954. * To speed it up, 1/30
  54955. * @param newTimeStep defines the new timestep to apply to this world.
  54956. */
  54957. setTimeStep(newTimeStep?: number): void;
  54958. /**
  54959. * Get the time step of the physics engine.
  54960. * @returns the current time step
  54961. */
  54962. getTimeStep(): number;
  54963. /**
  54964. * Set the sub time step of the physics engine.
  54965. * Default is 0 meaning there is no sub steps
  54966. * To increase physics resolution precision, set a small value (like 1 ms)
  54967. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54968. */
  54969. setSubTimeStep(subTimeStep?: number): void;
  54970. /**
  54971. * Get the sub time step of the physics engine.
  54972. * @returns the current sub time step
  54973. */
  54974. getSubTimeStep(): number;
  54975. /**
  54976. * Release all resources
  54977. */
  54978. dispose(): void;
  54979. /**
  54980. * Gets the name of the current physics plugin
  54981. * @returns the name of the plugin
  54982. */
  54983. getPhysicsPluginName(): string;
  54984. /**
  54985. * Adding a new impostor for the impostor tracking.
  54986. * This will be done by the impostor itself.
  54987. * @param impostor the impostor to add
  54988. */
  54989. addImpostor(impostor: PhysicsImpostor): void;
  54990. /**
  54991. * Remove an impostor from the engine.
  54992. * This impostor and its mesh will not longer be updated by the physics engine.
  54993. * @param impostor the impostor to remove
  54994. */
  54995. removeImpostor(impostor: PhysicsImpostor): void;
  54996. /**
  54997. * Add a joint to the physics engine
  54998. * @param mainImpostor defines the main impostor to which the joint is added.
  54999. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55000. * @param joint defines the joint that will connect both impostors.
  55001. */
  55002. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55003. /**
  55004. * Removes a joint from the simulation
  55005. * @param mainImpostor defines the impostor used with the joint
  55006. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55007. * @param joint defines the joint to remove
  55008. */
  55009. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55010. /**
  55011. * Called by the scene. No need to call it.
  55012. * @param delta defines the timespam between frames
  55013. */
  55014. _step(delta: number): void;
  55015. /**
  55016. * Gets the current plugin used to run the simulation
  55017. * @returns current plugin
  55018. */
  55019. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55020. /**
  55021. * Gets the list of physic impostors
  55022. * @returns an array of PhysicsImpostor
  55023. */
  55024. getImpostors(): Array<PhysicsImpostor>;
  55025. /**
  55026. * Gets the impostor for a physics enabled object
  55027. * @param object defines the object impersonated by the impostor
  55028. * @returns the PhysicsImpostor or null if not found
  55029. */
  55030. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55031. /**
  55032. * Gets the impostor for a physics body object
  55033. * @param body defines physics body used by the impostor
  55034. * @returns the PhysicsImpostor or null if not found
  55035. */
  55036. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55037. /**
  55038. * Does a raycast in the physics world
  55039. * @param from when should the ray start?
  55040. * @param to when should the ray end?
  55041. * @returns PhysicsRaycastResult
  55042. */
  55043. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55044. }
  55045. }
  55046. declare module BABYLON {
  55047. /** @hidden */
  55048. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55049. private _useDeltaForWorldStep;
  55050. world: any;
  55051. name: string;
  55052. private _physicsMaterials;
  55053. private _fixedTimeStep;
  55054. private _cannonRaycastResult;
  55055. private _raycastResult;
  55056. private _physicsBodysToRemoveAfterStep;
  55057. BJSCANNON: any;
  55058. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55059. setGravity(gravity: Vector3): void;
  55060. setTimeStep(timeStep: number): void;
  55061. getTimeStep(): number;
  55062. executeStep(delta: number): void;
  55063. private _removeMarkedPhysicsBodiesFromWorld;
  55064. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55065. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55066. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55067. private _processChildMeshes;
  55068. removePhysicsBody(impostor: PhysicsImpostor): void;
  55069. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55070. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55071. private _addMaterial;
  55072. private _checkWithEpsilon;
  55073. private _createShape;
  55074. private _createHeightmap;
  55075. private _minus90X;
  55076. private _plus90X;
  55077. private _tmpPosition;
  55078. private _tmpDeltaPosition;
  55079. private _tmpUnityRotation;
  55080. private _updatePhysicsBodyTransformation;
  55081. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55082. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55083. isSupported(): boolean;
  55084. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55085. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55086. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55087. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55088. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55089. getBodyMass(impostor: PhysicsImpostor): number;
  55090. getBodyFriction(impostor: PhysicsImpostor): number;
  55091. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55092. getBodyRestitution(impostor: PhysicsImpostor): number;
  55093. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55094. sleepBody(impostor: PhysicsImpostor): void;
  55095. wakeUpBody(impostor: PhysicsImpostor): void;
  55096. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55097. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55098. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55099. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55100. getRadius(impostor: PhysicsImpostor): number;
  55101. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55102. dispose(): void;
  55103. private _extendNamespace;
  55104. /**
  55105. * Does a raycast in the physics world
  55106. * @param from when should the ray start?
  55107. * @param to when should the ray end?
  55108. * @returns PhysicsRaycastResult
  55109. */
  55110. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55111. }
  55112. }
  55113. declare module BABYLON {
  55114. /** @hidden */
  55115. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55116. world: any;
  55117. name: string;
  55118. BJSOIMO: any;
  55119. private _raycastResult;
  55120. constructor(iterations?: number, oimoInjection?: any);
  55121. setGravity(gravity: Vector3): void;
  55122. setTimeStep(timeStep: number): void;
  55123. getTimeStep(): number;
  55124. private _tmpImpostorsArray;
  55125. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55126. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55127. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55128. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55129. private _tmpPositionVector;
  55130. removePhysicsBody(impostor: PhysicsImpostor): void;
  55131. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55132. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55133. isSupported(): boolean;
  55134. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55136. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55137. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55138. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55139. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55140. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55141. getBodyMass(impostor: PhysicsImpostor): number;
  55142. getBodyFriction(impostor: PhysicsImpostor): number;
  55143. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55144. getBodyRestitution(impostor: PhysicsImpostor): number;
  55145. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55146. sleepBody(impostor: PhysicsImpostor): void;
  55147. wakeUpBody(impostor: PhysicsImpostor): void;
  55148. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55149. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55150. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55151. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55152. getRadius(impostor: PhysicsImpostor): number;
  55153. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55154. dispose(): void;
  55155. /**
  55156. * Does a raycast in the physics world
  55157. * @param from when should the ray start?
  55158. * @param to when should the ray end?
  55159. * @returns PhysicsRaycastResult
  55160. */
  55161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55162. }
  55163. }
  55164. declare module BABYLON {
  55165. /**
  55166. * Class containing static functions to help procedurally build meshes
  55167. */
  55168. export class RibbonBuilder {
  55169. /**
  55170. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55171. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55172. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55173. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55174. * * 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
  55175. * * 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
  55176. * * 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
  55177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55178. * * 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
  55179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55180. * * 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
  55181. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55182. * * 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
  55183. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55185. * @param name defines the name of the mesh
  55186. * @param options defines the options used to create the mesh
  55187. * @param scene defines the hosting scene
  55188. * @returns the ribbon mesh
  55189. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55191. */
  55192. static CreateRibbon(name: string, options: {
  55193. pathArray: Vector3[][];
  55194. closeArray?: boolean;
  55195. closePath?: boolean;
  55196. offset?: number;
  55197. updatable?: boolean;
  55198. sideOrientation?: number;
  55199. frontUVs?: Vector4;
  55200. backUVs?: Vector4;
  55201. instance?: Mesh;
  55202. invertUV?: boolean;
  55203. uvs?: Vector2[];
  55204. colors?: Color4[];
  55205. }, scene?: Nullable<Scene>): Mesh;
  55206. }
  55207. }
  55208. declare module BABYLON {
  55209. /**
  55210. * Class containing static functions to help procedurally build meshes
  55211. */
  55212. export class ShapeBuilder {
  55213. /**
  55214. * 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.
  55215. * * 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.
  55216. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55217. * * 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.
  55218. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55219. * * 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
  55220. * * 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
  55221. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55223. * * 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
  55224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55226. * @param name defines the name of the mesh
  55227. * @param options defines the options used to create the mesh
  55228. * @param scene defines the hosting scene
  55229. * @returns the extruded shape mesh
  55230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55232. */
  55233. static ExtrudeShape(name: string, options: {
  55234. shape: Vector3[];
  55235. path: Vector3[];
  55236. scale?: number;
  55237. rotation?: number;
  55238. cap?: number;
  55239. updatable?: boolean;
  55240. sideOrientation?: number;
  55241. frontUVs?: Vector4;
  55242. backUVs?: Vector4;
  55243. instance?: Mesh;
  55244. invertUV?: boolean;
  55245. }, scene?: Nullable<Scene>): Mesh;
  55246. /**
  55247. * Creates an custom extruded shape mesh.
  55248. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55249. * * 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.
  55250. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55251. * * 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
  55252. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55253. * * 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
  55254. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55255. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55256. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55257. * * 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
  55258. * * 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
  55259. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55261. * * 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
  55262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55264. * @param name defines the name of the mesh
  55265. * @param options defines the options used to create the mesh
  55266. * @param scene defines the hosting scene
  55267. * @returns the custom extruded shape mesh
  55268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55269. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55271. */
  55272. static ExtrudeShapeCustom(name: string, options: {
  55273. shape: Vector3[];
  55274. path: Vector3[];
  55275. scaleFunction?: any;
  55276. rotationFunction?: any;
  55277. ribbonCloseArray?: boolean;
  55278. ribbonClosePath?: boolean;
  55279. cap?: number;
  55280. updatable?: boolean;
  55281. sideOrientation?: number;
  55282. frontUVs?: Vector4;
  55283. backUVs?: Vector4;
  55284. instance?: Mesh;
  55285. invertUV?: boolean;
  55286. }, scene?: Nullable<Scene>): Mesh;
  55287. private static _ExtrudeShapeGeneric;
  55288. }
  55289. }
  55290. declare module BABYLON {
  55291. /**
  55292. * AmmoJS Physics plugin
  55293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55294. * @see https://github.com/kripken/ammo.js/
  55295. */
  55296. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55297. private _useDeltaForWorldStep;
  55298. /**
  55299. * Reference to the Ammo library
  55300. */
  55301. bjsAMMO: any;
  55302. /**
  55303. * Created ammoJS world which physics bodies are added to
  55304. */
  55305. world: any;
  55306. /**
  55307. * Name of the plugin
  55308. */
  55309. name: string;
  55310. private _timeStep;
  55311. private _fixedTimeStep;
  55312. private _maxSteps;
  55313. private _tmpQuaternion;
  55314. private _tmpAmmoTransform;
  55315. private _tmpAmmoQuaternion;
  55316. private _tmpAmmoConcreteContactResultCallback;
  55317. private _collisionConfiguration;
  55318. private _dispatcher;
  55319. private _overlappingPairCache;
  55320. private _solver;
  55321. private _softBodySolver;
  55322. private _tmpAmmoVectorA;
  55323. private _tmpAmmoVectorB;
  55324. private _tmpAmmoVectorC;
  55325. private _tmpAmmoVectorD;
  55326. private _tmpContactCallbackResult;
  55327. private _tmpAmmoVectorRCA;
  55328. private _tmpAmmoVectorRCB;
  55329. private _raycastResult;
  55330. private static readonly DISABLE_COLLISION_FLAG;
  55331. private static readonly KINEMATIC_FLAG;
  55332. private static readonly DISABLE_DEACTIVATION_FLAG;
  55333. /**
  55334. * Initializes the ammoJS plugin
  55335. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55336. * @param ammoInjection can be used to inject your own ammo reference
  55337. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55338. */
  55339. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55340. /**
  55341. * Sets the gravity of the physics world (m/(s^2))
  55342. * @param gravity Gravity to set
  55343. */
  55344. setGravity(gravity: Vector3): void;
  55345. /**
  55346. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55347. * @param timeStep timestep to use in seconds
  55348. */
  55349. setTimeStep(timeStep: number): void;
  55350. /**
  55351. * 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)
  55352. * @param fixedTimeStep fixedTimeStep to use in seconds
  55353. */
  55354. setFixedTimeStep(fixedTimeStep: number): void;
  55355. /**
  55356. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55357. * @param maxSteps the maximum number of steps by the physics engine per frame
  55358. */
  55359. setMaxSteps(maxSteps: number): void;
  55360. /**
  55361. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55362. * @returns the current timestep in seconds
  55363. */
  55364. getTimeStep(): number;
  55365. /**
  55366. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55367. */
  55368. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55369. private _isImpostorInContact;
  55370. private _isImpostorPairInContact;
  55371. private _stepSimulation;
  55372. /**
  55373. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55374. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55375. * After the step the babylon meshes are set to the position of the physics imposters
  55376. * @param delta amount of time to step forward
  55377. * @param impostors array of imposters to update before/after the step
  55378. */
  55379. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55380. /**
  55381. * Update babylon mesh to match physics world object
  55382. * @param impostor imposter to match
  55383. */
  55384. private _afterSoftStep;
  55385. /**
  55386. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55387. * @param impostor imposter to match
  55388. */
  55389. private _ropeStep;
  55390. /**
  55391. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55392. * @param impostor imposter to match
  55393. */
  55394. private _softbodyOrClothStep;
  55395. private _tmpVector;
  55396. private _tmpMatrix;
  55397. /**
  55398. * Applies an impulse on the imposter
  55399. * @param impostor imposter to apply impulse to
  55400. * @param force amount of force to be applied to the imposter
  55401. * @param contactPoint the location to apply the impulse on the imposter
  55402. */
  55403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55404. /**
  55405. * Applies a force on the imposter
  55406. * @param impostor imposter to apply force
  55407. * @param force amount of force to be applied to the imposter
  55408. * @param contactPoint the location to apply the force on the imposter
  55409. */
  55410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55411. /**
  55412. * Creates a physics body using the plugin
  55413. * @param impostor the imposter to create the physics body on
  55414. */
  55415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55416. /**
  55417. * Removes the physics body from the imposter and disposes of the body's memory
  55418. * @param impostor imposter to remove the physics body from
  55419. */
  55420. removePhysicsBody(impostor: PhysicsImpostor): void;
  55421. /**
  55422. * Generates a joint
  55423. * @param impostorJoint the imposter joint to create the joint with
  55424. */
  55425. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55426. /**
  55427. * Removes a joint
  55428. * @param impostorJoint the imposter joint to remove the joint from
  55429. */
  55430. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55431. private _addMeshVerts;
  55432. /**
  55433. * Initialise the soft body vertices to match its object's (mesh) vertices
  55434. * Softbody vertices (nodes) are in world space and to match this
  55435. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55436. * @param impostor to create the softbody for
  55437. */
  55438. private _softVertexData;
  55439. /**
  55440. * Create an impostor's soft body
  55441. * @param impostor to create the softbody for
  55442. */
  55443. private _createSoftbody;
  55444. /**
  55445. * Create cloth for an impostor
  55446. * @param impostor to create the softbody for
  55447. */
  55448. private _createCloth;
  55449. /**
  55450. * Create rope for an impostor
  55451. * @param impostor to create the softbody for
  55452. */
  55453. private _createRope;
  55454. /**
  55455. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55456. * @param impostor to create the custom physics shape for
  55457. */
  55458. private _createCustom;
  55459. private _addHullVerts;
  55460. private _createShape;
  55461. /**
  55462. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55463. * @param impostor imposter containing the physics body and babylon object
  55464. */
  55465. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55466. /**
  55467. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55468. * @param impostor imposter containing the physics body and babylon object
  55469. * @param newPosition new position
  55470. * @param newRotation new rotation
  55471. */
  55472. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55473. /**
  55474. * If this plugin is supported
  55475. * @returns true if its supported
  55476. */
  55477. isSupported(): boolean;
  55478. /**
  55479. * Sets the linear velocity of the physics body
  55480. * @param impostor imposter to set the velocity on
  55481. * @param velocity velocity to set
  55482. */
  55483. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55484. /**
  55485. * Sets the angular velocity of the physics body
  55486. * @param impostor imposter to set the velocity on
  55487. * @param velocity velocity to set
  55488. */
  55489. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55490. /**
  55491. * gets the linear velocity
  55492. * @param impostor imposter to get linear velocity from
  55493. * @returns linear velocity
  55494. */
  55495. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55496. /**
  55497. * gets the angular velocity
  55498. * @param impostor imposter to get angular velocity from
  55499. * @returns angular velocity
  55500. */
  55501. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55502. /**
  55503. * Sets the mass of physics body
  55504. * @param impostor imposter to set the mass on
  55505. * @param mass mass to set
  55506. */
  55507. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55508. /**
  55509. * Gets the mass of the physics body
  55510. * @param impostor imposter to get the mass from
  55511. * @returns mass
  55512. */
  55513. getBodyMass(impostor: PhysicsImpostor): number;
  55514. /**
  55515. * Gets friction of the impostor
  55516. * @param impostor impostor to get friction from
  55517. * @returns friction value
  55518. */
  55519. getBodyFriction(impostor: PhysicsImpostor): number;
  55520. /**
  55521. * Sets friction of the impostor
  55522. * @param impostor impostor to set friction on
  55523. * @param friction friction value
  55524. */
  55525. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55526. /**
  55527. * Gets restitution of the impostor
  55528. * @param impostor impostor to get restitution from
  55529. * @returns restitution value
  55530. */
  55531. getBodyRestitution(impostor: PhysicsImpostor): number;
  55532. /**
  55533. * Sets resitution of the impostor
  55534. * @param impostor impostor to set resitution on
  55535. * @param restitution resitution value
  55536. */
  55537. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55538. /**
  55539. * Gets pressure inside the impostor
  55540. * @param impostor impostor to get pressure from
  55541. * @returns pressure value
  55542. */
  55543. getBodyPressure(impostor: PhysicsImpostor): number;
  55544. /**
  55545. * Sets pressure inside a soft body impostor
  55546. * Cloth and rope must remain 0 pressure
  55547. * @param impostor impostor to set pressure on
  55548. * @param pressure pressure value
  55549. */
  55550. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55551. /**
  55552. * Gets stiffness of the impostor
  55553. * @param impostor impostor to get stiffness from
  55554. * @returns pressure value
  55555. */
  55556. getBodyStiffness(impostor: PhysicsImpostor): number;
  55557. /**
  55558. * Sets stiffness of the impostor
  55559. * @param impostor impostor to set stiffness on
  55560. * @param stiffness stiffness value from 0 to 1
  55561. */
  55562. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55563. /**
  55564. * Gets velocityIterations of the impostor
  55565. * @param impostor impostor to get velocity iterations from
  55566. * @returns velocityIterations value
  55567. */
  55568. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55569. /**
  55570. * Sets velocityIterations of the impostor
  55571. * @param impostor impostor to set velocity iterations on
  55572. * @param velocityIterations velocityIterations value
  55573. */
  55574. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55575. /**
  55576. * Gets positionIterations of the impostor
  55577. * @param impostor impostor to get position iterations from
  55578. * @returns positionIterations value
  55579. */
  55580. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55581. /**
  55582. * Sets positionIterations of the impostor
  55583. * @param impostor impostor to set position on
  55584. * @param positionIterations positionIterations value
  55585. */
  55586. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55587. /**
  55588. * Append an anchor to a cloth object
  55589. * @param impostor is the cloth impostor to add anchor to
  55590. * @param otherImpostor is the rigid impostor to anchor to
  55591. * @param width ratio across width from 0 to 1
  55592. * @param height ratio up height from 0 to 1
  55593. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55594. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55595. */
  55596. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55597. /**
  55598. * Append an hook to a rope object
  55599. * @param impostor is the rope impostor to add hook to
  55600. * @param otherImpostor is the rigid impostor to hook to
  55601. * @param length ratio along the rope from 0 to 1
  55602. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55603. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55604. */
  55605. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55606. /**
  55607. * Sleeps the physics body and stops it from being active
  55608. * @param impostor impostor to sleep
  55609. */
  55610. sleepBody(impostor: PhysicsImpostor): void;
  55611. /**
  55612. * Activates the physics body
  55613. * @param impostor impostor to activate
  55614. */
  55615. wakeUpBody(impostor: PhysicsImpostor): void;
  55616. /**
  55617. * Updates the distance parameters of the joint
  55618. * @param joint joint to update
  55619. * @param maxDistance maximum distance of the joint
  55620. * @param minDistance minimum distance of the joint
  55621. */
  55622. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55623. /**
  55624. * Sets a motor on the joint
  55625. * @param joint joint to set motor on
  55626. * @param speed speed of the motor
  55627. * @param maxForce maximum force of the motor
  55628. * @param motorIndex index of the motor
  55629. */
  55630. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55631. /**
  55632. * Sets the motors limit
  55633. * @param joint joint to set limit on
  55634. * @param upperLimit upper limit
  55635. * @param lowerLimit lower limit
  55636. */
  55637. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55638. /**
  55639. * Syncs the position and rotation of a mesh with the impostor
  55640. * @param mesh mesh to sync
  55641. * @param impostor impostor to update the mesh with
  55642. */
  55643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55644. /**
  55645. * Gets the radius of the impostor
  55646. * @param impostor impostor to get radius from
  55647. * @returns the radius
  55648. */
  55649. getRadius(impostor: PhysicsImpostor): number;
  55650. /**
  55651. * Gets the box size of the impostor
  55652. * @param impostor impostor to get box size from
  55653. * @param result the resulting box size
  55654. */
  55655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55656. /**
  55657. * Disposes of the impostor
  55658. */
  55659. dispose(): void;
  55660. /**
  55661. * Does a raycast in the physics world
  55662. * @param from when should the ray start?
  55663. * @param to when should the ray end?
  55664. * @returns PhysicsRaycastResult
  55665. */
  55666. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. interface AbstractScene {
  55671. /**
  55672. * The list of reflection probes added to the scene
  55673. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55674. */
  55675. reflectionProbes: Array<ReflectionProbe>;
  55676. /**
  55677. * Removes the given reflection probe from this scene.
  55678. * @param toRemove The reflection probe to remove
  55679. * @returns The index of the removed reflection probe
  55680. */
  55681. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55682. /**
  55683. * Adds the given reflection probe to this scene.
  55684. * @param newReflectionProbe The reflection probe to add
  55685. */
  55686. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55687. }
  55688. /**
  55689. * Class used to generate realtime reflection / refraction cube textures
  55690. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55691. */
  55692. export class ReflectionProbe {
  55693. /** defines the name of the probe */
  55694. name: string;
  55695. private _scene;
  55696. private _renderTargetTexture;
  55697. private _projectionMatrix;
  55698. private _viewMatrix;
  55699. private _target;
  55700. private _add;
  55701. private _attachedMesh;
  55702. private _invertYAxis;
  55703. /** Gets or sets probe position (center of the cube map) */
  55704. position: Vector3;
  55705. /**
  55706. * Creates a new reflection probe
  55707. * @param name defines the name of the probe
  55708. * @param size defines the texture resolution (for each face)
  55709. * @param scene defines the hosting scene
  55710. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55711. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55712. */
  55713. constructor(
  55714. /** defines the name of the probe */
  55715. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55716. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55717. get samples(): number;
  55718. set samples(value: number);
  55719. /** Gets or sets the refresh rate to use (on every frame by default) */
  55720. get refreshRate(): number;
  55721. set refreshRate(value: number);
  55722. /**
  55723. * Gets the hosting scene
  55724. * @returns a Scene
  55725. */
  55726. getScene(): Scene;
  55727. /** Gets the internal CubeTexture used to render to */
  55728. get cubeTexture(): RenderTargetTexture;
  55729. /** Gets the list of meshes to render */
  55730. get renderList(): Nullable<AbstractMesh[]>;
  55731. /**
  55732. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55733. * @param mesh defines the mesh to attach to
  55734. */
  55735. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55736. /**
  55737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55738. * @param renderingGroupId The rendering group id corresponding to its index
  55739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55740. */
  55741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55742. /**
  55743. * Clean all associated resources
  55744. */
  55745. dispose(): void;
  55746. /**
  55747. * Converts the reflection probe information to a readable string for debug purpose.
  55748. * @param fullDetails Supports for multiple levels of logging within scene loading
  55749. * @returns the human readable reflection probe info
  55750. */
  55751. toString(fullDetails?: boolean): string;
  55752. /**
  55753. * Get the class name of the relfection probe.
  55754. * @returns "ReflectionProbe"
  55755. */
  55756. getClassName(): string;
  55757. /**
  55758. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55759. * @returns The JSON representation of the texture
  55760. */
  55761. serialize(): any;
  55762. /**
  55763. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55764. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55765. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55766. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55767. * @returns The parsed reflection probe if successful
  55768. */
  55769. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55770. }
  55771. }
  55772. declare module BABYLON {
  55773. /** @hidden */
  55774. export var _BabylonLoaderRegistered: boolean;
  55775. /**
  55776. * Helps setting up some configuration for the babylon file loader.
  55777. */
  55778. export class BabylonFileLoaderConfiguration {
  55779. /**
  55780. * The loader does not allow injecting custom physix engine into the plugins.
  55781. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55782. * So you could set this variable to your engine import to make it work.
  55783. */
  55784. static LoaderInjectedPhysicsEngine: any;
  55785. }
  55786. }
  55787. declare module BABYLON {
  55788. /**
  55789. * The Physically based simple base material of BJS.
  55790. *
  55791. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55792. * It is used as the base class for both the specGloss and metalRough conventions.
  55793. */
  55794. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55795. /**
  55796. * Number of Simultaneous lights allowed on the material.
  55797. */
  55798. maxSimultaneousLights: number;
  55799. /**
  55800. * If sets to true, disables all the lights affecting the material.
  55801. */
  55802. disableLighting: boolean;
  55803. /**
  55804. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55805. */
  55806. environmentTexture: BaseTexture;
  55807. /**
  55808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55809. */
  55810. invertNormalMapX: boolean;
  55811. /**
  55812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55813. */
  55814. invertNormalMapY: boolean;
  55815. /**
  55816. * Normal map used in the model.
  55817. */
  55818. normalTexture: BaseTexture;
  55819. /**
  55820. * Emissivie color used to self-illuminate the model.
  55821. */
  55822. emissiveColor: Color3;
  55823. /**
  55824. * Emissivie texture used to self-illuminate the model.
  55825. */
  55826. emissiveTexture: BaseTexture;
  55827. /**
  55828. * Occlusion Channel Strenght.
  55829. */
  55830. occlusionStrength: number;
  55831. /**
  55832. * Occlusion Texture of the material (adding extra occlusion effects).
  55833. */
  55834. occlusionTexture: BaseTexture;
  55835. /**
  55836. * Defines the alpha limits in alpha test mode.
  55837. */
  55838. alphaCutOff: number;
  55839. /**
  55840. * Gets the current double sided mode.
  55841. */
  55842. get doubleSided(): boolean;
  55843. /**
  55844. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55845. */
  55846. set doubleSided(value: boolean);
  55847. /**
  55848. * Stores the pre-calculated light information of a mesh in a texture.
  55849. */
  55850. lightmapTexture: BaseTexture;
  55851. /**
  55852. * If true, the light map contains occlusion information instead of lighting info.
  55853. */
  55854. useLightmapAsShadowmap: boolean;
  55855. /**
  55856. * Instantiates a new PBRMaterial instance.
  55857. *
  55858. * @param name The material name
  55859. * @param scene The scene the material will be use in.
  55860. */
  55861. constructor(name: string, scene: Scene);
  55862. getClassName(): string;
  55863. }
  55864. }
  55865. declare module BABYLON {
  55866. /**
  55867. * The PBR material of BJS following the metal roughness convention.
  55868. *
  55869. * This fits to the PBR convention in the GLTF definition:
  55870. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55871. */
  55872. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55873. /**
  55874. * The base color has two different interpretations depending on the value of metalness.
  55875. * When the material is a metal, the base color is the specific measured reflectance value
  55876. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55877. * of the material.
  55878. */
  55879. baseColor: Color3;
  55880. /**
  55881. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55882. * well as opacity information in the alpha channel.
  55883. */
  55884. baseTexture: BaseTexture;
  55885. /**
  55886. * Specifies the metallic scalar value of the material.
  55887. * Can also be used to scale the metalness values of the metallic texture.
  55888. */
  55889. metallic: number;
  55890. /**
  55891. * Specifies the roughness scalar value of the material.
  55892. * Can also be used to scale the roughness values of the metallic texture.
  55893. */
  55894. roughness: number;
  55895. /**
  55896. * Texture containing both the metallic value in the B channel and the
  55897. * roughness value in the G channel to keep better precision.
  55898. */
  55899. metallicRoughnessTexture: BaseTexture;
  55900. /**
  55901. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55902. *
  55903. * @param name The material name
  55904. * @param scene The scene the material will be use in.
  55905. */
  55906. constructor(name: string, scene: Scene);
  55907. /**
  55908. * Return the currrent class name of the material.
  55909. */
  55910. getClassName(): string;
  55911. /**
  55912. * Makes a duplicate of the current material.
  55913. * @param name - name to use for the new material.
  55914. */
  55915. clone(name: string): PBRMetallicRoughnessMaterial;
  55916. /**
  55917. * Serialize the material to a parsable JSON object.
  55918. */
  55919. serialize(): any;
  55920. /**
  55921. * Parses a JSON object correponding to the serialize function.
  55922. */
  55923. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55924. }
  55925. }
  55926. declare module BABYLON {
  55927. /**
  55928. * The PBR material of BJS following the specular glossiness convention.
  55929. *
  55930. * This fits to the PBR convention in the GLTF definition:
  55931. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55932. */
  55933. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55934. /**
  55935. * Specifies the diffuse color of the material.
  55936. */
  55937. diffuseColor: Color3;
  55938. /**
  55939. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55940. * channel.
  55941. */
  55942. diffuseTexture: BaseTexture;
  55943. /**
  55944. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55945. */
  55946. specularColor: Color3;
  55947. /**
  55948. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55949. */
  55950. glossiness: number;
  55951. /**
  55952. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55953. */
  55954. specularGlossinessTexture: BaseTexture;
  55955. /**
  55956. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55957. *
  55958. * @param name The material name
  55959. * @param scene The scene the material will be use in.
  55960. */
  55961. constructor(name: string, scene: Scene);
  55962. /**
  55963. * Return the currrent class name of the material.
  55964. */
  55965. getClassName(): string;
  55966. /**
  55967. * Makes a duplicate of the current material.
  55968. * @param name - name to use for the new material.
  55969. */
  55970. clone(name: string): PBRSpecularGlossinessMaterial;
  55971. /**
  55972. * Serialize the material to a parsable JSON object.
  55973. */
  55974. serialize(): any;
  55975. /**
  55976. * Parses a JSON object correponding to the serialize function.
  55977. */
  55978. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55979. }
  55980. }
  55981. declare module BABYLON {
  55982. /**
  55983. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55984. * It can help converting any input color in a desired output one. This can then be used to create effects
  55985. * from sepia, black and white to sixties or futuristic rendering...
  55986. *
  55987. * The only supported format is currently 3dl.
  55988. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55989. */
  55990. export class ColorGradingTexture extends BaseTexture {
  55991. /**
  55992. * The current texture matrix. (will always be identity in color grading texture)
  55993. */
  55994. private _textureMatrix;
  55995. /**
  55996. * The texture URL.
  55997. */
  55998. url: string;
  55999. /**
  56000. * Empty line regex stored for GC.
  56001. */
  56002. private static _noneEmptyLineRegex;
  56003. private _engine;
  56004. /**
  56005. * Instantiates a ColorGradingTexture from the following parameters.
  56006. *
  56007. * @param url The location of the color gradind data (currently only supporting 3dl)
  56008. * @param scene The scene the texture will be used in
  56009. */
  56010. constructor(url: string, scene: Scene);
  56011. /**
  56012. * Returns the texture matrix used in most of the material.
  56013. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56014. */
  56015. getTextureMatrix(): Matrix;
  56016. /**
  56017. * Occurs when the file being loaded is a .3dl LUT file.
  56018. */
  56019. private load3dlTexture;
  56020. /**
  56021. * Starts the loading process of the texture.
  56022. */
  56023. private loadTexture;
  56024. /**
  56025. * Clones the color gradind texture.
  56026. */
  56027. clone(): ColorGradingTexture;
  56028. /**
  56029. * Called during delayed load for textures.
  56030. */
  56031. delayLoad(): void;
  56032. /**
  56033. * Parses a color grading texture serialized by Babylon.
  56034. * @param parsedTexture The texture information being parsedTexture
  56035. * @param scene The scene to load the texture in
  56036. * @param rootUrl The root url of the data assets to load
  56037. * @return A color gradind texture
  56038. */
  56039. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56040. /**
  56041. * Serializes the LUT texture to json format.
  56042. */
  56043. serialize(): any;
  56044. }
  56045. }
  56046. declare module BABYLON {
  56047. /**
  56048. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56049. */
  56050. export class EquiRectangularCubeTexture extends BaseTexture {
  56051. /** The six faces of the cube. */
  56052. private static _FacesMapping;
  56053. private _noMipmap;
  56054. private _onLoad;
  56055. private _onError;
  56056. /** The size of the cubemap. */
  56057. private _size;
  56058. /** The buffer of the image. */
  56059. private _buffer;
  56060. /** The width of the input image. */
  56061. private _width;
  56062. /** The height of the input image. */
  56063. private _height;
  56064. /** The URL to the image. */
  56065. url: string;
  56066. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56067. coordinatesMode: number;
  56068. /**
  56069. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56070. * @param url The location of the image
  56071. * @param scene The scene the texture will be used in
  56072. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56073. * @param noMipmap Forces to not generate the mipmap if true
  56074. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56075. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56076. * @param onLoad — defines a callback called when texture is loaded
  56077. * @param onError — defines a callback called if there is an error
  56078. */
  56079. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56080. /**
  56081. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56082. */
  56083. private loadImage;
  56084. /**
  56085. * Convert the image buffer into a cubemap and create a CubeTexture.
  56086. */
  56087. private loadTexture;
  56088. /**
  56089. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56090. * @param buffer The ArrayBuffer that should be converted.
  56091. * @returns The buffer as Float32Array.
  56092. */
  56093. private getFloat32ArrayFromArrayBuffer;
  56094. /**
  56095. * Get the current class name of the texture useful for serialization or dynamic coding.
  56096. * @returns "EquiRectangularCubeTexture"
  56097. */
  56098. getClassName(): string;
  56099. /**
  56100. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56101. * @returns A clone of the current EquiRectangularCubeTexture.
  56102. */
  56103. clone(): EquiRectangularCubeTexture;
  56104. }
  56105. }
  56106. declare module BABYLON {
  56107. /**
  56108. * Based on jsTGALoader - Javascript loader for TGA file
  56109. * By Vincent Thibault
  56110. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56111. */
  56112. export class TGATools {
  56113. private static _TYPE_INDEXED;
  56114. private static _TYPE_RGB;
  56115. private static _TYPE_GREY;
  56116. private static _TYPE_RLE_INDEXED;
  56117. private static _TYPE_RLE_RGB;
  56118. private static _TYPE_RLE_GREY;
  56119. private static _ORIGIN_MASK;
  56120. private static _ORIGIN_SHIFT;
  56121. private static _ORIGIN_BL;
  56122. private static _ORIGIN_BR;
  56123. private static _ORIGIN_UL;
  56124. private static _ORIGIN_UR;
  56125. /**
  56126. * Gets the header of a TGA file
  56127. * @param data defines the TGA data
  56128. * @returns the header
  56129. */
  56130. static GetTGAHeader(data: Uint8Array): any;
  56131. /**
  56132. * Uploads TGA content to a Babylon Texture
  56133. * @hidden
  56134. */
  56135. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56136. /** @hidden */
  56137. 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;
  56138. /** @hidden */
  56139. 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;
  56140. /** @hidden */
  56141. 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;
  56142. /** @hidden */
  56143. 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;
  56144. /** @hidden */
  56145. 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;
  56146. /** @hidden */
  56147. 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;
  56148. }
  56149. }
  56150. declare module BABYLON {
  56151. /**
  56152. * Implementation of the TGA Texture Loader.
  56153. * @hidden
  56154. */
  56155. export class _TGATextureLoader implements IInternalTextureLoader {
  56156. /**
  56157. * Defines wether the loader supports cascade loading the different faces.
  56158. */
  56159. readonly supportCascades: boolean;
  56160. /**
  56161. * This returns if the loader support the current file information.
  56162. * @param extension defines the file extension of the file being loaded
  56163. * @returns true if the loader can load the specified file
  56164. */
  56165. canLoad(extension: string): boolean;
  56166. /**
  56167. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56168. * @param data contains the texture data
  56169. * @param texture defines the BabylonJS internal texture
  56170. * @param createPolynomials will be true if polynomials have been requested
  56171. * @param onLoad defines the callback to trigger once the texture is ready
  56172. * @param onError defines the callback to trigger in case of error
  56173. */
  56174. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56175. /**
  56176. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56177. * @param data contains the texture data
  56178. * @param texture defines the BabylonJS internal texture
  56179. * @param callback defines the method to call once ready to upload
  56180. */
  56181. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56182. }
  56183. }
  56184. declare module BABYLON {
  56185. /**
  56186. * Info about the .basis files
  56187. */
  56188. class BasisFileInfo {
  56189. /**
  56190. * If the file has alpha
  56191. */
  56192. hasAlpha: boolean;
  56193. /**
  56194. * Info about each image of the basis file
  56195. */
  56196. images: Array<{
  56197. levels: Array<{
  56198. width: number;
  56199. height: number;
  56200. transcodedPixels: ArrayBufferView;
  56201. }>;
  56202. }>;
  56203. }
  56204. /**
  56205. * Result of transcoding a basis file
  56206. */
  56207. class TranscodeResult {
  56208. /**
  56209. * Info about the .basis file
  56210. */
  56211. fileInfo: BasisFileInfo;
  56212. /**
  56213. * Format to use when loading the file
  56214. */
  56215. format: number;
  56216. }
  56217. /**
  56218. * Configuration options for the Basis transcoder
  56219. */
  56220. export class BasisTranscodeConfiguration {
  56221. /**
  56222. * Supported compression formats used to determine the supported output format of the transcoder
  56223. */
  56224. supportedCompressionFormats?: {
  56225. /**
  56226. * etc1 compression format
  56227. */
  56228. etc1?: boolean;
  56229. /**
  56230. * s3tc compression format
  56231. */
  56232. s3tc?: boolean;
  56233. /**
  56234. * pvrtc compression format
  56235. */
  56236. pvrtc?: boolean;
  56237. /**
  56238. * etc2 compression format
  56239. */
  56240. etc2?: boolean;
  56241. };
  56242. /**
  56243. * If mipmap levels should be loaded for transcoded images (Default: true)
  56244. */
  56245. loadMipmapLevels?: boolean;
  56246. /**
  56247. * Index of a single image to load (Default: all images)
  56248. */
  56249. loadSingleImage?: number;
  56250. }
  56251. /**
  56252. * Used to load .Basis files
  56253. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56254. */
  56255. export class BasisTools {
  56256. private static _IgnoreSupportedFormats;
  56257. /**
  56258. * URL to use when loading the basis transcoder
  56259. */
  56260. static JSModuleURL: string;
  56261. /**
  56262. * URL to use when loading the wasm module for the transcoder
  56263. */
  56264. static WasmModuleURL: string;
  56265. /**
  56266. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56267. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56268. * @returns internal format corresponding to the Basis format
  56269. */
  56270. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56271. private static _WorkerPromise;
  56272. private static _Worker;
  56273. private static _actionId;
  56274. private static _CreateWorkerAsync;
  56275. /**
  56276. * Transcodes a loaded image file to compressed pixel data
  56277. * @param data image data to transcode
  56278. * @param config configuration options for the transcoding
  56279. * @returns a promise resulting in the transcoded image
  56280. */
  56281. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56282. /**
  56283. * Loads a texture from the transcode result
  56284. * @param texture texture load to
  56285. * @param transcodeResult the result of transcoding the basis file to load from
  56286. */
  56287. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56288. }
  56289. }
  56290. declare module BABYLON {
  56291. /**
  56292. * Loader for .basis file format
  56293. */
  56294. export class _BasisTextureLoader implements IInternalTextureLoader {
  56295. /**
  56296. * Defines whether the loader supports cascade loading the different faces.
  56297. */
  56298. readonly supportCascades: boolean;
  56299. /**
  56300. * This returns if the loader support the current file information.
  56301. * @param extension defines the file extension of the file being loaded
  56302. * @returns true if the loader can load the specified file
  56303. */
  56304. canLoad(extension: string): boolean;
  56305. /**
  56306. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56307. * @param data contains the texture data
  56308. * @param texture defines the BabylonJS internal texture
  56309. * @param createPolynomials will be true if polynomials have been requested
  56310. * @param onLoad defines the callback to trigger once the texture is ready
  56311. * @param onError defines the callback to trigger in case of error
  56312. */
  56313. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56314. /**
  56315. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56316. * @param data contains the texture data
  56317. * @param texture defines the BabylonJS internal texture
  56318. * @param callback defines the method to call once ready to upload
  56319. */
  56320. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56321. }
  56322. }
  56323. declare module BABYLON {
  56324. /**
  56325. * 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.
  56326. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56327. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56328. */
  56329. export class CustomProceduralTexture extends ProceduralTexture {
  56330. private _animate;
  56331. private _time;
  56332. private _config;
  56333. private _texturePath;
  56334. /**
  56335. * Instantiates a new Custom Procedural Texture.
  56336. * 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.
  56337. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56338. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56339. * @param name Define the name of the texture
  56340. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56341. * @param size Define the size of the texture to create
  56342. * @param scene Define the scene the texture belongs to
  56343. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56344. * @param generateMipMaps Define if the texture should creates mip maps or not
  56345. */
  56346. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56347. private _loadJson;
  56348. /**
  56349. * Is the texture ready to be used ? (rendered at least once)
  56350. * @returns true if ready, otherwise, false.
  56351. */
  56352. isReady(): boolean;
  56353. /**
  56354. * Render the texture to its associated render target.
  56355. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56356. */
  56357. render(useCameraPostProcess?: boolean): void;
  56358. /**
  56359. * Update the list of dependant textures samplers in the shader.
  56360. */
  56361. updateTextures(): void;
  56362. /**
  56363. * Update the uniform values of the procedural texture in the shader.
  56364. */
  56365. updateShaderUniforms(): void;
  56366. /**
  56367. * Define if the texture animates or not.
  56368. */
  56369. get animate(): boolean;
  56370. set animate(value: boolean);
  56371. }
  56372. }
  56373. declare module BABYLON {
  56374. /** @hidden */
  56375. export var noisePixelShader: {
  56376. name: string;
  56377. shader: string;
  56378. };
  56379. }
  56380. declare module BABYLON {
  56381. /**
  56382. * Class used to generate noise procedural textures
  56383. */
  56384. export class NoiseProceduralTexture extends ProceduralTexture {
  56385. private _time;
  56386. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56387. brightness: number;
  56388. /** Defines the number of octaves to process */
  56389. octaves: number;
  56390. /** Defines the level of persistence (0.8 by default) */
  56391. persistence: number;
  56392. /** Gets or sets animation speed factor (default is 1) */
  56393. animationSpeedFactor: number;
  56394. /**
  56395. * Creates a new NoiseProceduralTexture
  56396. * @param name defines the name fo the texture
  56397. * @param size defines the size of the texture (default is 256)
  56398. * @param scene defines the hosting scene
  56399. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56400. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56401. */
  56402. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56403. private _updateShaderUniforms;
  56404. protected _getDefines(): string;
  56405. /** Generate the current state of the procedural texture */
  56406. render(useCameraPostProcess?: boolean): void;
  56407. /**
  56408. * Serializes this noise procedural texture
  56409. * @returns a serialized noise procedural texture object
  56410. */
  56411. serialize(): any;
  56412. /**
  56413. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56414. * @param parsedTexture defines parsed texture data
  56415. * @param scene defines the current scene
  56416. * @param rootUrl defines the root URL containing noise procedural texture information
  56417. * @returns a parsed NoiseProceduralTexture
  56418. */
  56419. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56420. }
  56421. }
  56422. declare module BABYLON {
  56423. /**
  56424. * Raw cube texture where the raw buffers are passed in
  56425. */
  56426. export class RawCubeTexture extends CubeTexture {
  56427. /**
  56428. * Creates a cube texture where the raw buffers are passed in.
  56429. * @param scene defines the scene the texture is attached to
  56430. * @param data defines the array of data to use to create each face
  56431. * @param size defines the size of the textures
  56432. * @param format defines the format of the data
  56433. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56434. * @param generateMipMaps defines if the engine should generate the mip levels
  56435. * @param invertY defines if data must be stored with Y axis inverted
  56436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56437. * @param compression defines the compression used (null by default)
  56438. */
  56439. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56440. /**
  56441. * Updates the raw cube texture.
  56442. * @param data defines the data to store
  56443. * @param format defines the data format
  56444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56445. * @param invertY defines if data must be stored with Y axis inverted
  56446. * @param compression defines the compression used (null by default)
  56447. * @param level defines which level of the texture to update
  56448. */
  56449. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56450. /**
  56451. * Updates a raw cube texture with RGBD encoded data.
  56452. * @param data defines the array of data [mipmap][face] to use to create each face
  56453. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56456. * @returns a promsie that resolves when the operation is complete
  56457. */
  56458. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56459. /**
  56460. * Clones the raw cube texture.
  56461. * @return a new cube texture
  56462. */
  56463. clone(): CubeTexture;
  56464. /** @hidden */
  56465. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56466. }
  56467. }
  56468. declare module BABYLON {
  56469. /**
  56470. * Class used to store 3D textures containing user data
  56471. */
  56472. export class RawTexture3D extends Texture {
  56473. /** Gets or sets the texture format to use */
  56474. format: number;
  56475. private _engine;
  56476. /**
  56477. * Create a new RawTexture3D
  56478. * @param data defines the data of the texture
  56479. * @param width defines the width of the texture
  56480. * @param height defines the height of the texture
  56481. * @param depth defines the depth of the texture
  56482. * @param format defines the texture format to use
  56483. * @param scene defines the hosting scene
  56484. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56485. * @param invertY defines if texture must be stored with Y axis inverted
  56486. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56487. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56488. */
  56489. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56490. /** Gets or sets the texture format to use */
  56491. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56492. /**
  56493. * Update the texture with new data
  56494. * @param data defines the data to store in the texture
  56495. */
  56496. update(data: ArrayBufferView): void;
  56497. }
  56498. }
  56499. declare module BABYLON {
  56500. /**
  56501. * Class used to store 2D array textures containing user data
  56502. */
  56503. export class RawTexture2DArray extends Texture {
  56504. /** Gets or sets the texture format to use */
  56505. format: number;
  56506. private _engine;
  56507. /**
  56508. * Create a new RawTexture2DArray
  56509. * @param data defines the data of the texture
  56510. * @param width defines the width of the texture
  56511. * @param height defines the height of the texture
  56512. * @param depth defines the number of layers of the texture
  56513. * @param format defines the texture format to use
  56514. * @param scene defines the hosting scene
  56515. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56516. * @param invertY defines if texture must be stored with Y axis inverted
  56517. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56518. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56519. */
  56520. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56521. /** Gets or sets the texture format to use */
  56522. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56523. /**
  56524. * Update the texture with new data
  56525. * @param data defines the data to store in the texture
  56526. */
  56527. update(data: ArrayBufferView): void;
  56528. }
  56529. }
  56530. declare module BABYLON {
  56531. /**
  56532. * Creates a refraction texture used by refraction channel of the standard material.
  56533. * It is like a mirror but to see through a material.
  56534. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56535. */
  56536. export class RefractionTexture extends RenderTargetTexture {
  56537. /**
  56538. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56539. * 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.
  56540. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56541. */
  56542. refractionPlane: Plane;
  56543. /**
  56544. * Define how deep under the surface we should see.
  56545. */
  56546. depth: number;
  56547. /**
  56548. * Creates a refraction texture used by refraction channel of the standard material.
  56549. * It is like a mirror but to see through a material.
  56550. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56551. * @param name Define the texture name
  56552. * @param size Define the size of the underlying texture
  56553. * @param scene Define the scene the refraction belongs to
  56554. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56555. */
  56556. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56557. /**
  56558. * Clone the refraction texture.
  56559. * @returns the cloned texture
  56560. */
  56561. clone(): RefractionTexture;
  56562. /**
  56563. * Serialize the texture to a JSON representation you could use in Parse later on
  56564. * @returns the serialized JSON representation
  56565. */
  56566. serialize(): any;
  56567. }
  56568. }
  56569. declare module BABYLON {
  56570. /**
  56571. * Defines the options related to the creation of an HtmlElementTexture
  56572. */
  56573. export interface IHtmlElementTextureOptions {
  56574. /**
  56575. * Defines wether mip maps should be created or not.
  56576. */
  56577. generateMipMaps?: boolean;
  56578. /**
  56579. * Defines the sampling mode of the texture.
  56580. */
  56581. samplingMode?: number;
  56582. /**
  56583. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56584. */
  56585. engine: Nullable<ThinEngine>;
  56586. /**
  56587. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56588. */
  56589. scene: Nullable<Scene>;
  56590. }
  56591. /**
  56592. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56593. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56594. * is automatically managed.
  56595. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56596. * in your application.
  56597. *
  56598. * As the update is not automatic, you need to call them manually.
  56599. */
  56600. export class HtmlElementTexture extends BaseTexture {
  56601. /**
  56602. * The texture URL.
  56603. */
  56604. element: HTMLVideoElement | HTMLCanvasElement;
  56605. private static readonly DefaultOptions;
  56606. private _textureMatrix;
  56607. private _engine;
  56608. private _isVideo;
  56609. private _generateMipMaps;
  56610. private _samplingMode;
  56611. /**
  56612. * Instantiates a HtmlElementTexture from the following parameters.
  56613. *
  56614. * @param name Defines the name of the texture
  56615. * @param element Defines the video or canvas the texture is filled with
  56616. * @param options Defines the other none mandatory texture creation options
  56617. */
  56618. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56619. private _createInternalTexture;
  56620. /**
  56621. * Returns the texture matrix used in most of the material.
  56622. */
  56623. getTextureMatrix(): Matrix;
  56624. /**
  56625. * Updates the content of the texture.
  56626. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56627. */
  56628. update(invertY?: Nullable<boolean>): void;
  56629. }
  56630. }
  56631. declare module BABYLON {
  56632. /**
  56633. * Defines the basic options interface of a TexturePacker Frame
  56634. */
  56635. export interface ITexturePackerFrame {
  56636. /**
  56637. * The frame ID
  56638. */
  56639. id: number;
  56640. /**
  56641. * The frames Scale
  56642. */
  56643. scale: Vector2;
  56644. /**
  56645. * The Frames offset
  56646. */
  56647. offset: Vector2;
  56648. }
  56649. /**
  56650. * This is a support class for frame Data on texture packer sets.
  56651. */
  56652. export class TexturePackerFrame implements ITexturePackerFrame {
  56653. /**
  56654. * The frame ID
  56655. */
  56656. id: number;
  56657. /**
  56658. * The frames Scale
  56659. */
  56660. scale: Vector2;
  56661. /**
  56662. * The Frames offset
  56663. */
  56664. offset: Vector2;
  56665. /**
  56666. * Initializes a texture package frame.
  56667. * @param id The numerical frame identifier
  56668. * @param scale Scalar Vector2 for UV frame
  56669. * @param offset Vector2 for the frame position in UV units.
  56670. * @returns TexturePackerFrame
  56671. */
  56672. constructor(id: number, scale: Vector2, offset: Vector2);
  56673. }
  56674. }
  56675. declare module BABYLON {
  56676. /**
  56677. * Defines the basic options interface of a TexturePacker
  56678. */
  56679. export interface ITexturePackerOptions {
  56680. /**
  56681. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56682. */
  56683. map?: string[];
  56684. /**
  56685. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56686. */
  56687. uvsIn?: string;
  56688. /**
  56689. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56690. */
  56691. uvsOut?: string;
  56692. /**
  56693. * number representing the layout style. Defaults to LAYOUT_STRIP
  56694. */
  56695. layout?: number;
  56696. /**
  56697. * number of columns if using custom column count layout(2). This defaults to 4.
  56698. */
  56699. colnum?: number;
  56700. /**
  56701. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56702. */
  56703. updateInputMeshes?: boolean;
  56704. /**
  56705. * boolean flag to dispose all the source textures. Defaults to true.
  56706. */
  56707. disposeSources?: boolean;
  56708. /**
  56709. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56710. */
  56711. fillBlanks?: boolean;
  56712. /**
  56713. * string value representing the context fill style color. Defaults to 'black'.
  56714. */
  56715. customFillColor?: string;
  56716. /**
  56717. * Width and Height Value of each Frame in the TexturePacker Sets
  56718. */
  56719. frameSize?: number;
  56720. /**
  56721. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56722. */
  56723. paddingRatio?: number;
  56724. /**
  56725. * Number that declares the fill method for the padding gutter.
  56726. */
  56727. paddingMode?: number;
  56728. /**
  56729. * If in SUBUV_COLOR padding mode what color to use.
  56730. */
  56731. paddingColor?: Color3 | Color4;
  56732. }
  56733. /**
  56734. * Defines the basic interface of a TexturePacker JSON File
  56735. */
  56736. export interface ITexturePackerJSON {
  56737. /**
  56738. * The frame ID
  56739. */
  56740. name: string;
  56741. /**
  56742. * The base64 channel data
  56743. */
  56744. sets: any;
  56745. /**
  56746. * The options of the Packer
  56747. */
  56748. options: ITexturePackerOptions;
  56749. /**
  56750. * The frame data of the Packer
  56751. */
  56752. frames: Array<number>;
  56753. }
  56754. /**
  56755. * This is a support class that generates a series of packed texture sets.
  56756. * @see https://doc.babylonjs.com/babylon101/materials
  56757. */
  56758. export class TexturePacker {
  56759. /** Packer Layout Constant 0 */
  56760. static readonly LAYOUT_STRIP: number;
  56761. /** Packer Layout Constant 1 */
  56762. static readonly LAYOUT_POWER2: number;
  56763. /** Packer Layout Constant 2 */
  56764. static readonly LAYOUT_COLNUM: number;
  56765. /** Packer Layout Constant 0 */
  56766. static readonly SUBUV_WRAP: number;
  56767. /** Packer Layout Constant 1 */
  56768. static readonly SUBUV_EXTEND: number;
  56769. /** Packer Layout Constant 2 */
  56770. static readonly SUBUV_COLOR: number;
  56771. /** The Name of the Texture Package */
  56772. name: string;
  56773. /** The scene scope of the TexturePacker */
  56774. scene: Scene;
  56775. /** The Meshes to target */
  56776. meshes: AbstractMesh[];
  56777. /** Arguments passed with the Constructor */
  56778. options: ITexturePackerOptions;
  56779. /** The promise that is started upon initialization */
  56780. promise: Nullable<Promise<TexturePacker | string>>;
  56781. /** The Container object for the channel sets that are generated */
  56782. sets: object;
  56783. /** The Container array for the frames that are generated */
  56784. frames: TexturePackerFrame[];
  56785. /** The expected number of textures the system is parsing. */
  56786. private _expecting;
  56787. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56788. private _paddingValue;
  56789. /**
  56790. * Initializes a texture package series from an array of meshes or a single mesh.
  56791. * @param name The name of the package
  56792. * @param meshes The target meshes to compose the package from
  56793. * @param options The arguments that texture packer should follow while building.
  56794. * @param scene The scene which the textures are scoped to.
  56795. * @returns TexturePacker
  56796. */
  56797. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56798. /**
  56799. * Starts the package process
  56800. * @param resolve The promises resolution function
  56801. * @returns TexturePacker
  56802. */
  56803. private _createFrames;
  56804. /**
  56805. * Calculates the Size of the Channel Sets
  56806. * @returns Vector2
  56807. */
  56808. private _calculateSize;
  56809. /**
  56810. * Calculates the UV data for the frames.
  56811. * @param baseSize the base frameSize
  56812. * @param padding the base frame padding
  56813. * @param dtSize size of the Dynamic Texture for that channel
  56814. * @param dtUnits is 1/dtSize
  56815. * @param update flag to update the input meshes
  56816. */
  56817. private _calculateMeshUVFrames;
  56818. /**
  56819. * Calculates the frames Offset.
  56820. * @param index of the frame
  56821. * @returns Vector2
  56822. */
  56823. private _getFrameOffset;
  56824. /**
  56825. * Updates a Mesh to the frame data
  56826. * @param mesh that is the target
  56827. * @param frameID or the frame index
  56828. */
  56829. private _updateMeshUV;
  56830. /**
  56831. * Updates a Meshes materials to use the texture packer channels
  56832. * @param m is the mesh to target
  56833. * @param force all channels on the packer to be set.
  56834. */
  56835. private _updateTextureReferences;
  56836. /**
  56837. * Public method to set a Mesh to a frame
  56838. * @param m that is the target
  56839. * @param frameID or the frame index
  56840. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56841. */
  56842. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56843. /**
  56844. * Starts the async promise to compile the texture packer.
  56845. * @returns Promise<void>
  56846. */
  56847. processAsync(): Promise<void>;
  56848. /**
  56849. * Disposes all textures associated with this packer
  56850. */
  56851. dispose(): void;
  56852. /**
  56853. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56854. * @param imageType is the image type to use.
  56855. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56856. */
  56857. download(imageType?: string, quality?: number): void;
  56858. /**
  56859. * Public method to load a texturePacker JSON file.
  56860. * @param data of the JSON file in string format.
  56861. */
  56862. updateFromJSON(data: string): void;
  56863. }
  56864. }
  56865. declare module BABYLON {
  56866. /**
  56867. * Enum used to define the target of a block
  56868. */
  56869. export enum NodeMaterialBlockTargets {
  56870. /** Vertex shader */
  56871. Vertex = 1,
  56872. /** Fragment shader */
  56873. Fragment = 2,
  56874. /** Neutral */
  56875. Neutral = 4,
  56876. /** Vertex and Fragment */
  56877. VertexAndFragment = 3
  56878. }
  56879. }
  56880. declare module BABYLON {
  56881. /**
  56882. * Defines the kind of connection point for node based material
  56883. */
  56884. export enum NodeMaterialBlockConnectionPointTypes {
  56885. /** Float */
  56886. Float = 1,
  56887. /** Int */
  56888. Int = 2,
  56889. /** Vector2 */
  56890. Vector2 = 4,
  56891. /** Vector3 */
  56892. Vector3 = 8,
  56893. /** Vector4 */
  56894. Vector4 = 16,
  56895. /** Color3 */
  56896. Color3 = 32,
  56897. /** Color4 */
  56898. Color4 = 64,
  56899. /** Matrix */
  56900. Matrix = 128,
  56901. /** Detect type based on connection */
  56902. AutoDetect = 1024,
  56903. /** Output type that will be defined by input type */
  56904. BasedOnInput = 2048
  56905. }
  56906. }
  56907. declare module BABYLON {
  56908. /**
  56909. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56910. */
  56911. export enum NodeMaterialBlockConnectionPointMode {
  56912. /** Value is an uniform */
  56913. Uniform = 0,
  56914. /** Value is a mesh attribute */
  56915. Attribute = 1,
  56916. /** Value is a varying between vertex and fragment shaders */
  56917. Varying = 2,
  56918. /** Mode is undefined */
  56919. Undefined = 3
  56920. }
  56921. }
  56922. declare module BABYLON {
  56923. /**
  56924. * Enum used to define system values e.g. values automatically provided by the system
  56925. */
  56926. export enum NodeMaterialSystemValues {
  56927. /** World */
  56928. World = 1,
  56929. /** View */
  56930. View = 2,
  56931. /** Projection */
  56932. Projection = 3,
  56933. /** ViewProjection */
  56934. ViewProjection = 4,
  56935. /** WorldView */
  56936. WorldView = 5,
  56937. /** WorldViewProjection */
  56938. WorldViewProjection = 6,
  56939. /** CameraPosition */
  56940. CameraPosition = 7,
  56941. /** Fog Color */
  56942. FogColor = 8,
  56943. /** Delta time */
  56944. DeltaTime = 9
  56945. }
  56946. }
  56947. declare module BABYLON {
  56948. /**
  56949. * Root class for all node material optimizers
  56950. */
  56951. export class NodeMaterialOptimizer {
  56952. /**
  56953. * Function used to optimize a NodeMaterial graph
  56954. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56955. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56956. */
  56957. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56958. }
  56959. }
  56960. declare module BABYLON {
  56961. /**
  56962. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56963. */
  56964. export class TransformBlock extends NodeMaterialBlock {
  56965. /**
  56966. * Defines the value to use to complement W value to transform it to a Vector4
  56967. */
  56968. complementW: number;
  56969. /**
  56970. * Defines the value to use to complement z value to transform it to a Vector4
  56971. */
  56972. complementZ: number;
  56973. /**
  56974. * Creates a new TransformBlock
  56975. * @param name defines the block name
  56976. */
  56977. constructor(name: string);
  56978. /**
  56979. * Gets the current class name
  56980. * @returns the class name
  56981. */
  56982. getClassName(): string;
  56983. /**
  56984. * Gets the vector input
  56985. */
  56986. get vector(): NodeMaterialConnectionPoint;
  56987. /**
  56988. * Gets the output component
  56989. */
  56990. get output(): NodeMaterialConnectionPoint;
  56991. /**
  56992. * Gets the xyz output component
  56993. */
  56994. get xyz(): NodeMaterialConnectionPoint;
  56995. /**
  56996. * Gets the matrix transform input
  56997. */
  56998. get transform(): NodeMaterialConnectionPoint;
  56999. protected _buildBlock(state: NodeMaterialBuildState): this;
  57000. serialize(): any;
  57001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57002. protected _dumpPropertiesCode(): string;
  57003. }
  57004. }
  57005. declare module BABYLON {
  57006. /**
  57007. * Block used to output the vertex position
  57008. */
  57009. export class VertexOutputBlock extends NodeMaterialBlock {
  57010. /**
  57011. * Creates a new VertexOutputBlock
  57012. * @param name defines the block name
  57013. */
  57014. constructor(name: string);
  57015. /**
  57016. * Gets the current class name
  57017. * @returns the class name
  57018. */
  57019. getClassName(): string;
  57020. /**
  57021. * Gets the vector input component
  57022. */
  57023. get vector(): NodeMaterialConnectionPoint;
  57024. protected _buildBlock(state: NodeMaterialBuildState): this;
  57025. }
  57026. }
  57027. declare module BABYLON {
  57028. /**
  57029. * Block used to output the final color
  57030. */
  57031. export class FragmentOutputBlock extends NodeMaterialBlock {
  57032. /**
  57033. * Create a new FragmentOutputBlock
  57034. * @param name defines the block name
  57035. */
  57036. constructor(name: string);
  57037. /**
  57038. * Gets the current class name
  57039. * @returns the class name
  57040. */
  57041. getClassName(): string;
  57042. /**
  57043. * Gets the rgba input component
  57044. */
  57045. get rgba(): NodeMaterialConnectionPoint;
  57046. /**
  57047. * Gets the rgb input component
  57048. */
  57049. get rgb(): NodeMaterialConnectionPoint;
  57050. /**
  57051. * Gets the a input component
  57052. */
  57053. get a(): NodeMaterialConnectionPoint;
  57054. protected _buildBlock(state: NodeMaterialBuildState): this;
  57055. }
  57056. }
  57057. declare module BABYLON {
  57058. /**
  57059. * Block used to read a reflection texture from a sampler
  57060. */
  57061. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57062. private _define3DName;
  57063. private _defineCubicName;
  57064. private _defineExplicitName;
  57065. private _defineProjectionName;
  57066. private _defineLocalCubicName;
  57067. private _defineSphericalName;
  57068. private _definePlanarName;
  57069. private _defineEquirectangularName;
  57070. private _defineMirroredEquirectangularFixedName;
  57071. private _defineEquirectangularFixedName;
  57072. private _defineSkyboxName;
  57073. private _cubeSamplerName;
  57074. private _2DSamplerName;
  57075. private _positionUVWName;
  57076. private _directionWName;
  57077. private _reflectionCoordsName;
  57078. private _reflection2DCoordsName;
  57079. private _reflectionColorName;
  57080. private _reflectionMatrixName;
  57081. /**
  57082. * Gets or sets the texture associated with the node
  57083. */
  57084. texture: Nullable<BaseTexture>;
  57085. /**
  57086. * Create a new TextureBlock
  57087. * @param name defines the block name
  57088. */
  57089. constructor(name: string);
  57090. /**
  57091. * Gets the current class name
  57092. * @returns the class name
  57093. */
  57094. getClassName(): string;
  57095. /**
  57096. * Gets the world position input component
  57097. */
  57098. get position(): NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the world position input component
  57101. */
  57102. get worldPosition(): NodeMaterialConnectionPoint;
  57103. /**
  57104. * Gets the world normal input component
  57105. */
  57106. get worldNormal(): NodeMaterialConnectionPoint;
  57107. /**
  57108. * Gets the world input component
  57109. */
  57110. get world(): NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the camera (or eye) position component
  57113. */
  57114. get cameraPosition(): NodeMaterialConnectionPoint;
  57115. /**
  57116. * Gets the view input component
  57117. */
  57118. get view(): NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the rgb output component
  57121. */
  57122. get rgb(): NodeMaterialConnectionPoint;
  57123. /**
  57124. * Gets the r output component
  57125. */
  57126. get r(): NodeMaterialConnectionPoint;
  57127. /**
  57128. * Gets the g output component
  57129. */
  57130. get g(): NodeMaterialConnectionPoint;
  57131. /**
  57132. * Gets the b output component
  57133. */
  57134. get b(): NodeMaterialConnectionPoint;
  57135. autoConfigure(material: NodeMaterial): void;
  57136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57137. isReady(): boolean;
  57138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57139. private _injectVertexCode;
  57140. private _writeOutput;
  57141. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57142. protected _dumpPropertiesCode(): string;
  57143. serialize(): any;
  57144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57145. }
  57146. }
  57147. declare module BABYLON {
  57148. /**
  57149. * Interface used to configure the node material editor
  57150. */
  57151. export interface INodeMaterialEditorOptions {
  57152. /** Define the URl to load node editor script */
  57153. editorURL?: string;
  57154. }
  57155. /** @hidden */
  57156. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57157. NORMAL: boolean;
  57158. TANGENT: boolean;
  57159. UV1: boolean;
  57160. /** BONES */
  57161. NUM_BONE_INFLUENCERS: number;
  57162. BonesPerMesh: number;
  57163. BONETEXTURE: boolean;
  57164. /** MORPH TARGETS */
  57165. MORPHTARGETS: boolean;
  57166. MORPHTARGETS_NORMAL: boolean;
  57167. MORPHTARGETS_TANGENT: boolean;
  57168. MORPHTARGETS_UV: boolean;
  57169. NUM_MORPH_INFLUENCERS: number;
  57170. /** IMAGE PROCESSING */
  57171. IMAGEPROCESSING: boolean;
  57172. VIGNETTE: boolean;
  57173. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57174. VIGNETTEBLENDMODEOPAQUE: boolean;
  57175. TONEMAPPING: boolean;
  57176. TONEMAPPING_ACES: boolean;
  57177. CONTRAST: boolean;
  57178. EXPOSURE: boolean;
  57179. COLORCURVES: boolean;
  57180. COLORGRADING: boolean;
  57181. COLORGRADING3D: boolean;
  57182. SAMPLER3DGREENDEPTH: boolean;
  57183. SAMPLER3DBGRMAP: boolean;
  57184. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57185. /** MISC. */
  57186. BUMPDIRECTUV: number;
  57187. constructor();
  57188. setValue(name: string, value: boolean): void;
  57189. }
  57190. /**
  57191. * Class used to configure NodeMaterial
  57192. */
  57193. export interface INodeMaterialOptions {
  57194. /**
  57195. * Defines if blocks should emit comments
  57196. */
  57197. emitComments: boolean;
  57198. }
  57199. /**
  57200. * Class used to create a node based material built by assembling shader blocks
  57201. */
  57202. export class NodeMaterial extends PushMaterial {
  57203. private static _BuildIdGenerator;
  57204. private _options;
  57205. private _vertexCompilationState;
  57206. private _fragmentCompilationState;
  57207. private _sharedData;
  57208. private _buildId;
  57209. private _buildWasSuccessful;
  57210. private _cachedWorldViewMatrix;
  57211. private _cachedWorldViewProjectionMatrix;
  57212. private _optimizers;
  57213. private _animationFrame;
  57214. /** Define the Url to load node editor script */
  57215. static EditorURL: string;
  57216. /** Define the Url to load snippets */
  57217. static SnippetUrl: string;
  57218. private BJSNODEMATERIALEDITOR;
  57219. /** Get the inspector from bundle or global */
  57220. private _getGlobalNodeMaterialEditor;
  57221. /**
  57222. * Gets or sets data used by visual editor
  57223. * @see https://nme.babylonjs.com
  57224. */
  57225. editorData: any;
  57226. /**
  57227. * 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)
  57228. */
  57229. ignoreAlpha: boolean;
  57230. /**
  57231. * Defines the maximum number of lights that can be used in the material
  57232. */
  57233. maxSimultaneousLights: number;
  57234. /**
  57235. * Observable raised when the material is built
  57236. */
  57237. onBuildObservable: Observable<NodeMaterial>;
  57238. /**
  57239. * Gets or sets the root nodes of the material vertex shader
  57240. */
  57241. _vertexOutputNodes: NodeMaterialBlock[];
  57242. /**
  57243. * Gets or sets the root nodes of the material fragment (pixel) shader
  57244. */
  57245. _fragmentOutputNodes: NodeMaterialBlock[];
  57246. /** Gets or sets options to control the node material overall behavior */
  57247. get options(): INodeMaterialOptions;
  57248. set options(options: INodeMaterialOptions);
  57249. /**
  57250. * Default configuration related to image processing available in the standard Material.
  57251. */
  57252. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57253. /**
  57254. * Gets the image processing configuration used either in this material.
  57255. */
  57256. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57257. /**
  57258. * Sets the Default image processing configuration used either in the this material.
  57259. *
  57260. * If sets to null, the scene one is in use.
  57261. */
  57262. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57263. /**
  57264. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57265. */
  57266. attachedBlocks: NodeMaterialBlock[];
  57267. /**
  57268. * Create a new node based material
  57269. * @param name defines the material name
  57270. * @param scene defines the hosting scene
  57271. * @param options defines creation option
  57272. */
  57273. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57274. /**
  57275. * Gets the current class name of the material e.g. "NodeMaterial"
  57276. * @returns the class name
  57277. */
  57278. getClassName(): string;
  57279. /**
  57280. * Keep track of the image processing observer to allow dispose and replace.
  57281. */
  57282. private _imageProcessingObserver;
  57283. /**
  57284. * Attaches a new image processing configuration to the Standard Material.
  57285. * @param configuration
  57286. */
  57287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57288. /**
  57289. * Get a block by its name
  57290. * @param name defines the name of the block to retrieve
  57291. * @returns the required block or null if not found
  57292. */
  57293. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57294. /**
  57295. * Get a block by its name
  57296. * @param predicate defines the predicate used to find the good candidate
  57297. * @returns the required block or null if not found
  57298. */
  57299. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57300. /**
  57301. * Get an input block by its name
  57302. * @param predicate defines the predicate used to find the good candidate
  57303. * @returns the required input block or null if not found
  57304. */
  57305. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57306. /**
  57307. * Gets the list of input blocks attached to this material
  57308. * @returns an array of InputBlocks
  57309. */
  57310. getInputBlocks(): InputBlock[];
  57311. /**
  57312. * Adds a new optimizer to the list of optimizers
  57313. * @param optimizer defines the optimizers to add
  57314. * @returns the current material
  57315. */
  57316. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57317. /**
  57318. * Remove an optimizer from the list of optimizers
  57319. * @param optimizer defines the optimizers to remove
  57320. * @returns the current material
  57321. */
  57322. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57323. /**
  57324. * Add a new block to the list of output nodes
  57325. * @param node defines the node to add
  57326. * @returns the current material
  57327. */
  57328. addOutputNode(node: NodeMaterialBlock): this;
  57329. /**
  57330. * Remove a block from the list of root nodes
  57331. * @param node defines the node to remove
  57332. * @returns the current material
  57333. */
  57334. removeOutputNode(node: NodeMaterialBlock): this;
  57335. private _addVertexOutputNode;
  57336. private _removeVertexOutputNode;
  57337. private _addFragmentOutputNode;
  57338. private _removeFragmentOutputNode;
  57339. /**
  57340. * Specifies if the material will require alpha blending
  57341. * @returns a boolean specifying if alpha blending is needed
  57342. */
  57343. needAlphaBlending(): boolean;
  57344. /**
  57345. * Specifies if this material should be rendered in alpha test mode
  57346. * @returns a boolean specifying if an alpha test is needed.
  57347. */
  57348. needAlphaTesting(): boolean;
  57349. private _initializeBlock;
  57350. private _resetDualBlocks;
  57351. /**
  57352. * Remove a block from the current node material
  57353. * @param block defines the block to remove
  57354. */
  57355. removeBlock(block: NodeMaterialBlock): void;
  57356. /**
  57357. * Build the material and generates the inner effect
  57358. * @param verbose defines if the build should log activity
  57359. */
  57360. build(verbose?: boolean): void;
  57361. /**
  57362. * Runs an otpimization phase to try to improve the shader code
  57363. */
  57364. optimize(): void;
  57365. private _prepareDefinesForAttributes;
  57366. /**
  57367. * Get if the submesh is ready to be used and all its information available.
  57368. * Child classes can use it to update shaders
  57369. * @param mesh defines the mesh to check
  57370. * @param subMesh defines which submesh to check
  57371. * @param useInstances specifies that instances should be used
  57372. * @returns a boolean indicating that the submesh is ready or not
  57373. */
  57374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57375. /**
  57376. * Get a string representing the shaders built by the current node graph
  57377. */
  57378. get compiledShaders(): string;
  57379. /**
  57380. * Binds the world matrix to the material
  57381. * @param world defines the world transformation matrix
  57382. */
  57383. bindOnlyWorldMatrix(world: Matrix): void;
  57384. /**
  57385. * Binds the submesh to this material by preparing the effect and shader to draw
  57386. * @param world defines the world transformation matrix
  57387. * @param mesh defines the mesh containing the submesh
  57388. * @param subMesh defines the submesh to bind the material to
  57389. */
  57390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57391. /**
  57392. * Gets the active textures from the material
  57393. * @returns an array of textures
  57394. */
  57395. getActiveTextures(): BaseTexture[];
  57396. /**
  57397. * Gets the list of texture blocks
  57398. * @returns an array of texture blocks
  57399. */
  57400. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57401. /**
  57402. * Specifies if the material uses a texture
  57403. * @param texture defines the texture to check against the material
  57404. * @returns a boolean specifying if the material uses the texture
  57405. */
  57406. hasTexture(texture: BaseTexture): boolean;
  57407. /**
  57408. * Disposes the material
  57409. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57410. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57411. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57412. */
  57413. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57414. /** Creates the node editor window. */
  57415. private _createNodeEditor;
  57416. /**
  57417. * Launch the node material editor
  57418. * @param config Define the configuration of the editor
  57419. * @return a promise fulfilled when the node editor is visible
  57420. */
  57421. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57422. /**
  57423. * Clear the current material
  57424. */
  57425. clear(): void;
  57426. /**
  57427. * Clear the current material and set it to a default state
  57428. */
  57429. setToDefault(): void;
  57430. /**
  57431. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57432. * @param url defines the url to load from
  57433. * @returns a promise that will fullfil when the material is fully loaded
  57434. */
  57435. loadAsync(url: string): Promise<void>;
  57436. private _gatherBlocks;
  57437. /**
  57438. * Generate a string containing the code declaration required to create an equivalent of this material
  57439. * @returns a string
  57440. */
  57441. generateCode(): string;
  57442. /**
  57443. * Serializes this material in a JSON representation
  57444. * @returns the serialized material object
  57445. */
  57446. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57447. private _restoreConnections;
  57448. /**
  57449. * Clear the current graph and load a new one from a serialization object
  57450. * @param source defines the JSON representation of the material
  57451. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57452. */
  57453. loadFromSerialization(source: any, rootUrl?: string): void;
  57454. /**
  57455. * Makes a duplicate of the current material.
  57456. * @param name - name to use for the new material.
  57457. */
  57458. clone(name: string): NodeMaterial;
  57459. /**
  57460. * Creates a node material from parsed material data
  57461. * @param source defines the JSON representation of the material
  57462. * @param scene defines the hosting scene
  57463. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57464. * @returns a new node material
  57465. */
  57466. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57467. /**
  57468. * Creates a node material from a snippet saved in a remote file
  57469. * @param name defines the name of the material to create
  57470. * @param url defines the url to load from
  57471. * @param scene defines the hosting scene
  57472. * @returns a promise that will resolve to the new node material
  57473. */
  57474. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57475. /**
  57476. * Creates a node material from a snippet saved by the node material editor
  57477. * @param snippetId defines the snippet to load
  57478. * @param scene defines the hosting scene
  57479. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57480. * @returns a promise that will resolve to the new node material
  57481. */
  57482. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57483. /**
  57484. * Creates a new node material set to default basic configuration
  57485. * @param name defines the name of the material
  57486. * @param scene defines the hosting scene
  57487. * @returns a new NodeMaterial
  57488. */
  57489. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57490. }
  57491. }
  57492. declare module BABYLON {
  57493. /**
  57494. * Block used to read a texture from a sampler
  57495. */
  57496. export class TextureBlock extends NodeMaterialBlock {
  57497. private _defineName;
  57498. private _linearDefineName;
  57499. private _tempTextureRead;
  57500. private _samplerName;
  57501. private _transformedUVName;
  57502. private _textureTransformName;
  57503. private _textureInfoName;
  57504. private _mainUVName;
  57505. private _mainUVDefineName;
  57506. /**
  57507. * Gets or sets the texture associated with the node
  57508. */
  57509. texture: Nullable<Texture>;
  57510. /**
  57511. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57512. */
  57513. convertToGammaSpace: boolean;
  57514. /**
  57515. * Create a new TextureBlock
  57516. * @param name defines the block name
  57517. */
  57518. constructor(name: string);
  57519. /**
  57520. * Gets the current class name
  57521. * @returns the class name
  57522. */
  57523. getClassName(): string;
  57524. /**
  57525. * Gets the uv input component
  57526. */
  57527. get uv(): NodeMaterialConnectionPoint;
  57528. /**
  57529. * Gets the rgba output component
  57530. */
  57531. get rgba(): NodeMaterialConnectionPoint;
  57532. /**
  57533. * Gets the rgb output component
  57534. */
  57535. get rgb(): NodeMaterialConnectionPoint;
  57536. /**
  57537. * Gets the r output component
  57538. */
  57539. get r(): NodeMaterialConnectionPoint;
  57540. /**
  57541. * Gets the g output component
  57542. */
  57543. get g(): NodeMaterialConnectionPoint;
  57544. /**
  57545. * Gets the b output component
  57546. */
  57547. get b(): NodeMaterialConnectionPoint;
  57548. /**
  57549. * Gets the a output component
  57550. */
  57551. get a(): NodeMaterialConnectionPoint;
  57552. get target(): NodeMaterialBlockTargets;
  57553. autoConfigure(material: NodeMaterial): void;
  57554. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57556. isReady(): boolean;
  57557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57558. private get _isMixed();
  57559. private _injectVertexCode;
  57560. private _writeTextureRead;
  57561. private _writeOutput;
  57562. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57563. protected _dumpPropertiesCode(): string;
  57564. serialize(): any;
  57565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57566. }
  57567. }
  57568. declare module BABYLON {
  57569. /**
  57570. * Class used to store shared data between 2 NodeMaterialBuildState
  57571. */
  57572. export class NodeMaterialBuildStateSharedData {
  57573. /**
  57574. * Gets the list of emitted varyings
  57575. */
  57576. temps: string[];
  57577. /**
  57578. * Gets the list of emitted varyings
  57579. */
  57580. varyings: string[];
  57581. /**
  57582. * Gets the varying declaration string
  57583. */
  57584. varyingDeclaration: string;
  57585. /**
  57586. * Input blocks
  57587. */
  57588. inputBlocks: InputBlock[];
  57589. /**
  57590. * Input blocks
  57591. */
  57592. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57593. /**
  57594. * Bindable blocks (Blocks that need to set data to the effect)
  57595. */
  57596. bindableBlocks: NodeMaterialBlock[];
  57597. /**
  57598. * List of blocks that can provide a compilation fallback
  57599. */
  57600. blocksWithFallbacks: NodeMaterialBlock[];
  57601. /**
  57602. * List of blocks that can provide a define update
  57603. */
  57604. blocksWithDefines: NodeMaterialBlock[];
  57605. /**
  57606. * List of blocks that can provide a repeatable content
  57607. */
  57608. repeatableContentBlocks: NodeMaterialBlock[];
  57609. /**
  57610. * List of blocks that can provide a dynamic list of uniforms
  57611. */
  57612. dynamicUniformBlocks: NodeMaterialBlock[];
  57613. /**
  57614. * List of blocks that can block the isReady function for the material
  57615. */
  57616. blockingBlocks: NodeMaterialBlock[];
  57617. /**
  57618. * Gets the list of animated inputs
  57619. */
  57620. animatedInputs: InputBlock[];
  57621. /**
  57622. * Build Id used to avoid multiple recompilations
  57623. */
  57624. buildId: number;
  57625. /** List of emitted variables */
  57626. variableNames: {
  57627. [key: string]: number;
  57628. };
  57629. /** List of emitted defines */
  57630. defineNames: {
  57631. [key: string]: number;
  57632. };
  57633. /** Should emit comments? */
  57634. emitComments: boolean;
  57635. /** Emit build activity */
  57636. verbose: boolean;
  57637. /** Gets or sets the hosting scene */
  57638. scene: Scene;
  57639. /**
  57640. * Gets the compilation hints emitted at compilation time
  57641. */
  57642. hints: {
  57643. needWorldViewMatrix: boolean;
  57644. needWorldViewProjectionMatrix: boolean;
  57645. needAlphaBlending: boolean;
  57646. needAlphaTesting: boolean;
  57647. };
  57648. /**
  57649. * List of compilation checks
  57650. */
  57651. checks: {
  57652. emitVertex: boolean;
  57653. emitFragment: boolean;
  57654. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57655. };
  57656. /** Creates a new shared data */
  57657. constructor();
  57658. /**
  57659. * Emits console errors and exceptions if there is a failing check
  57660. */
  57661. emitErrors(): void;
  57662. }
  57663. }
  57664. declare module BABYLON {
  57665. /**
  57666. * Class used to store node based material build state
  57667. */
  57668. export class NodeMaterialBuildState {
  57669. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57670. supportUniformBuffers: boolean;
  57671. /**
  57672. * Gets the list of emitted attributes
  57673. */
  57674. attributes: string[];
  57675. /**
  57676. * Gets the list of emitted uniforms
  57677. */
  57678. uniforms: string[];
  57679. /**
  57680. * Gets the list of emitted constants
  57681. */
  57682. constants: string[];
  57683. /**
  57684. * Gets the list of emitted samplers
  57685. */
  57686. samplers: string[];
  57687. /**
  57688. * Gets the list of emitted functions
  57689. */
  57690. functions: {
  57691. [key: string]: string;
  57692. };
  57693. /**
  57694. * Gets the list of emitted extensions
  57695. */
  57696. extensions: {
  57697. [key: string]: string;
  57698. };
  57699. /**
  57700. * Gets the target of the compilation state
  57701. */
  57702. target: NodeMaterialBlockTargets;
  57703. /**
  57704. * Gets the list of emitted counters
  57705. */
  57706. counters: {
  57707. [key: string]: number;
  57708. };
  57709. /**
  57710. * Shared data between multiple NodeMaterialBuildState instances
  57711. */
  57712. sharedData: NodeMaterialBuildStateSharedData;
  57713. /** @hidden */
  57714. _vertexState: NodeMaterialBuildState;
  57715. /** @hidden */
  57716. _attributeDeclaration: string;
  57717. /** @hidden */
  57718. _uniformDeclaration: string;
  57719. /** @hidden */
  57720. _constantDeclaration: string;
  57721. /** @hidden */
  57722. _samplerDeclaration: string;
  57723. /** @hidden */
  57724. _varyingTransfer: string;
  57725. private _repeatableContentAnchorIndex;
  57726. /** @hidden */
  57727. _builtCompilationString: string;
  57728. /**
  57729. * Gets the emitted compilation strings
  57730. */
  57731. compilationString: string;
  57732. /**
  57733. * Finalize the compilation strings
  57734. * @param state defines the current compilation state
  57735. */
  57736. finalize(state: NodeMaterialBuildState): void;
  57737. /** @hidden */
  57738. get _repeatableContentAnchor(): string;
  57739. /** @hidden */
  57740. _getFreeVariableName(prefix: string): string;
  57741. /** @hidden */
  57742. _getFreeDefineName(prefix: string): string;
  57743. /** @hidden */
  57744. _excludeVariableName(name: string): void;
  57745. /** @hidden */
  57746. _emit2DSampler(name: string): void;
  57747. /** @hidden */
  57748. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57749. /** @hidden */
  57750. _emitExtension(name: string, extension: string): void;
  57751. /** @hidden */
  57752. _emitFunction(name: string, code: string, comments: string): void;
  57753. /** @hidden */
  57754. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57755. replaceStrings?: {
  57756. search: RegExp;
  57757. replace: string;
  57758. }[];
  57759. repeatKey?: string;
  57760. }): string;
  57761. /** @hidden */
  57762. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57763. repeatKey?: string;
  57764. removeAttributes?: boolean;
  57765. removeUniforms?: boolean;
  57766. removeVaryings?: boolean;
  57767. removeIfDef?: boolean;
  57768. replaceStrings?: {
  57769. search: RegExp;
  57770. replace: string;
  57771. }[];
  57772. }, storeKey?: string): void;
  57773. /** @hidden */
  57774. _registerTempVariable(name: string): boolean;
  57775. /** @hidden */
  57776. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57777. /** @hidden */
  57778. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57779. /** @hidden */
  57780. _emitFloat(value: number): string;
  57781. }
  57782. }
  57783. declare module BABYLON {
  57784. /**
  57785. * Defines a block that can be used inside a node based material
  57786. */
  57787. export class NodeMaterialBlock {
  57788. private _buildId;
  57789. private _buildTarget;
  57790. private _target;
  57791. private _isFinalMerger;
  57792. private _isInput;
  57793. protected _isUnique: boolean;
  57794. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57795. inputsAreExclusive: boolean;
  57796. /** @hidden */
  57797. _codeVariableName: string;
  57798. /** @hidden */
  57799. _inputs: NodeMaterialConnectionPoint[];
  57800. /** @hidden */
  57801. _outputs: NodeMaterialConnectionPoint[];
  57802. /** @hidden */
  57803. _preparationId: number;
  57804. /**
  57805. * Gets or sets the name of the block
  57806. */
  57807. name: string;
  57808. /**
  57809. * Gets or sets the unique id of the node
  57810. */
  57811. uniqueId: number;
  57812. /**
  57813. * Gets or sets the comments associated with this block
  57814. */
  57815. comments: string;
  57816. /**
  57817. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57818. */
  57819. get isUnique(): boolean;
  57820. /**
  57821. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57822. */
  57823. get isFinalMerger(): boolean;
  57824. /**
  57825. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57826. */
  57827. get isInput(): boolean;
  57828. /**
  57829. * Gets or sets the build Id
  57830. */
  57831. get buildId(): number;
  57832. set buildId(value: number);
  57833. /**
  57834. * Gets or sets the target of the block
  57835. */
  57836. get target(): NodeMaterialBlockTargets;
  57837. set target(value: NodeMaterialBlockTargets);
  57838. /**
  57839. * Gets the list of input points
  57840. */
  57841. get inputs(): NodeMaterialConnectionPoint[];
  57842. /** Gets the list of output points */
  57843. get outputs(): NodeMaterialConnectionPoint[];
  57844. /**
  57845. * Find an input by its name
  57846. * @param name defines the name of the input to look for
  57847. * @returns the input or null if not found
  57848. */
  57849. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57850. /**
  57851. * Find an output by its name
  57852. * @param name defines the name of the outputto look for
  57853. * @returns the output or null if not found
  57854. */
  57855. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57856. /**
  57857. * Creates a new NodeMaterialBlock
  57858. * @param name defines the block name
  57859. * @param target defines the target of that block (Vertex by default)
  57860. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57861. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57862. */
  57863. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57864. /**
  57865. * Initialize the block and prepare the context for build
  57866. * @param state defines the state that will be used for the build
  57867. */
  57868. initialize(state: NodeMaterialBuildState): void;
  57869. /**
  57870. * Bind data to effect. Will only be called for blocks with isBindable === true
  57871. * @param effect defines the effect to bind data to
  57872. * @param nodeMaterial defines the hosting NodeMaterial
  57873. * @param mesh defines the mesh that will be rendered
  57874. */
  57875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57876. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57877. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57878. protected _writeFloat(value: number): string;
  57879. /**
  57880. * Gets the current class name e.g. "NodeMaterialBlock"
  57881. * @returns the class name
  57882. */
  57883. getClassName(): string;
  57884. /**
  57885. * Register a new input. Must be called inside a block constructor
  57886. * @param name defines the connection point name
  57887. * @param type defines the connection point type
  57888. * @param isOptional defines a boolean indicating that this input can be omitted
  57889. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57890. * @returns the current block
  57891. */
  57892. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57893. /**
  57894. * Register a new output. Must be called inside a block constructor
  57895. * @param name defines the connection point name
  57896. * @param type defines the connection point type
  57897. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57898. * @returns the current block
  57899. */
  57900. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57901. /**
  57902. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57903. * @param forOutput defines an optional connection point to check compatibility with
  57904. * @returns the first available input or null
  57905. */
  57906. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57907. /**
  57908. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57909. * @param forBlock defines an optional block to check compatibility with
  57910. * @returns the first available input or null
  57911. */
  57912. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57913. /**
  57914. * Gets the sibling of the given output
  57915. * @param current defines the current output
  57916. * @returns the next output in the list or null
  57917. */
  57918. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57919. /**
  57920. * Connect current block with another block
  57921. * @param other defines the block to connect with
  57922. * @param options define the various options to help pick the right connections
  57923. * @returns the current block
  57924. */
  57925. connectTo(other: NodeMaterialBlock, options?: {
  57926. input?: string;
  57927. output?: string;
  57928. outputSwizzle?: string;
  57929. }): this | undefined;
  57930. protected _buildBlock(state: NodeMaterialBuildState): void;
  57931. /**
  57932. * Add uniforms, samplers and uniform buffers at compilation time
  57933. * @param state defines the state to update
  57934. * @param nodeMaterial defines the node material requesting the update
  57935. * @param defines defines the material defines to update
  57936. * @param uniformBuffers defines the list of uniform buffer names
  57937. */
  57938. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57939. /**
  57940. * Add potential fallbacks if shader compilation fails
  57941. * @param mesh defines the mesh to be rendered
  57942. * @param fallbacks defines the current prioritized list of fallbacks
  57943. */
  57944. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57945. /**
  57946. * Initialize defines for shader compilation
  57947. * @param mesh defines the mesh to be rendered
  57948. * @param nodeMaterial defines the node material requesting the update
  57949. * @param defines defines the material defines to update
  57950. * @param useInstances specifies that instances should be used
  57951. */
  57952. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57953. /**
  57954. * Update defines for shader compilation
  57955. * @param mesh defines the mesh to be rendered
  57956. * @param nodeMaterial defines the node material requesting the update
  57957. * @param defines defines the material defines to update
  57958. * @param useInstances specifies that instances should be used
  57959. */
  57960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57961. /**
  57962. * Lets the block try to connect some inputs automatically
  57963. * @param material defines the hosting NodeMaterial
  57964. */
  57965. autoConfigure(material: NodeMaterial): void;
  57966. /**
  57967. * Function called when a block is declared as repeatable content generator
  57968. * @param vertexShaderState defines the current compilation state for the vertex shader
  57969. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57970. * @param mesh defines the mesh to be rendered
  57971. * @param defines defines the material defines to update
  57972. */
  57973. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57974. /**
  57975. * Checks if the block is ready
  57976. * @param mesh defines the mesh to be rendered
  57977. * @param nodeMaterial defines the node material requesting the update
  57978. * @param defines defines the material defines to update
  57979. * @param useInstances specifies that instances should be used
  57980. * @returns true if the block is ready
  57981. */
  57982. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57983. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57984. private _processBuild;
  57985. /**
  57986. * Compile the current node and generate the shader code
  57987. * @param state defines the current compilation state (uniforms, samplers, current string)
  57988. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57989. * @returns true if already built
  57990. */
  57991. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57992. protected _inputRename(name: string): string;
  57993. protected _outputRename(name: string): string;
  57994. protected _dumpPropertiesCode(): string;
  57995. /** @hidden */
  57996. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57997. /** @hidden */
  57998. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57999. /**
  58000. * Clone the current block to a new identical block
  58001. * @param scene defines the hosting scene
  58002. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58003. * @returns a copy of the current block
  58004. */
  58005. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58006. /**
  58007. * Serializes this block in a JSON representation
  58008. * @returns the serialized block object
  58009. */
  58010. serialize(): any;
  58011. /** @hidden */
  58012. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58013. /**
  58014. * Release resources
  58015. */
  58016. dispose(): void;
  58017. }
  58018. }
  58019. declare module BABYLON {
  58020. /**
  58021. * Enum defining the type of animations supported by InputBlock
  58022. */
  58023. export enum AnimatedInputBlockTypes {
  58024. /** No animation */
  58025. None = 0,
  58026. /** Time based animation. Will only work for floats */
  58027. Time = 1
  58028. }
  58029. }
  58030. declare module BABYLON {
  58031. /**
  58032. * Block used to expose an input value
  58033. */
  58034. export class InputBlock extends NodeMaterialBlock {
  58035. private _mode;
  58036. private _associatedVariableName;
  58037. private _storedValue;
  58038. private _valueCallback;
  58039. private _type;
  58040. private _animationType;
  58041. /** Gets or set a value used to limit the range of float values */
  58042. min: number;
  58043. /** Gets or set a value used to limit the range of float values */
  58044. max: number;
  58045. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58046. isBoolean: boolean;
  58047. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58048. matrixMode: number;
  58049. /** @hidden */
  58050. _systemValue: Nullable<NodeMaterialSystemValues>;
  58051. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58052. visibleInInspector: boolean;
  58053. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58054. isConstant: boolean;
  58055. /** Gets or sets the group to use to display this block in the Inspector */
  58056. groupInInspector: string;
  58057. /** Gets an observable raised when the value is changed */
  58058. onValueChangedObservable: Observable<InputBlock>;
  58059. /**
  58060. * Gets or sets the connection point type (default is float)
  58061. */
  58062. get type(): NodeMaterialBlockConnectionPointTypes;
  58063. /**
  58064. * Creates a new InputBlock
  58065. * @param name defines the block name
  58066. * @param target defines the target of that block (Vertex by default)
  58067. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58068. */
  58069. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58070. /**
  58071. * Gets the output component
  58072. */
  58073. get output(): NodeMaterialConnectionPoint;
  58074. /**
  58075. * Set the source of this connection point to a vertex attribute
  58076. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58077. * @returns the current connection point
  58078. */
  58079. setAsAttribute(attributeName?: string): InputBlock;
  58080. /**
  58081. * Set the source of this connection point to a system value
  58082. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58083. * @returns the current connection point
  58084. */
  58085. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58086. /**
  58087. * Gets or sets the value of that point.
  58088. * Please note that this value will be ignored if valueCallback is defined
  58089. */
  58090. get value(): any;
  58091. set value(value: any);
  58092. /**
  58093. * Gets or sets a callback used to get the value of that point.
  58094. * Please note that setting this value will force the connection point to ignore the value property
  58095. */
  58096. get valueCallback(): () => any;
  58097. set valueCallback(value: () => any);
  58098. /**
  58099. * Gets or sets the associated variable name in the shader
  58100. */
  58101. get associatedVariableName(): string;
  58102. set associatedVariableName(value: string);
  58103. /** Gets or sets the type of animation applied to the input */
  58104. get animationType(): AnimatedInputBlockTypes;
  58105. set animationType(value: AnimatedInputBlockTypes);
  58106. /**
  58107. * Gets a boolean indicating that this connection point not defined yet
  58108. */
  58109. get isUndefined(): boolean;
  58110. /**
  58111. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58112. * In this case the connection point name must be the name of the uniform to use.
  58113. * Can only be set on inputs
  58114. */
  58115. get isUniform(): boolean;
  58116. set isUniform(value: boolean);
  58117. /**
  58118. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58119. * In this case the connection point name must be the name of the attribute to use
  58120. * Can only be set on inputs
  58121. */
  58122. get isAttribute(): boolean;
  58123. set isAttribute(value: boolean);
  58124. /**
  58125. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58126. * Can only be set on exit points
  58127. */
  58128. get isVarying(): boolean;
  58129. set isVarying(value: boolean);
  58130. /**
  58131. * Gets a boolean indicating that the current connection point is a system value
  58132. */
  58133. get isSystemValue(): boolean;
  58134. /**
  58135. * Gets or sets the current well known value or null if not defined as a system value
  58136. */
  58137. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58138. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58139. /**
  58140. * Gets the current class name
  58141. * @returns the class name
  58142. */
  58143. getClassName(): string;
  58144. /**
  58145. * Animate the input if animationType !== None
  58146. * @param scene defines the rendering scene
  58147. */
  58148. animate(scene: Scene): void;
  58149. private _emitDefine;
  58150. initialize(state: NodeMaterialBuildState): void;
  58151. /**
  58152. * Set the input block to its default value (based on its type)
  58153. */
  58154. setDefaultValue(): void;
  58155. private _emitConstant;
  58156. private _emit;
  58157. /** @hidden */
  58158. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58159. /** @hidden */
  58160. _transmit(effect: Effect, scene: Scene): void;
  58161. protected _buildBlock(state: NodeMaterialBuildState): void;
  58162. protected _dumpPropertiesCode(): string;
  58163. dispose(): void;
  58164. serialize(): any;
  58165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58166. }
  58167. }
  58168. declare module BABYLON {
  58169. /**
  58170. * Enum used to define the compatibility state between two connection points
  58171. */
  58172. export enum NodeMaterialConnectionPointCompatibilityStates {
  58173. /** Points are compatibles */
  58174. Compatible = 0,
  58175. /** Points are incompatible because of their types */
  58176. TypeIncompatible = 1,
  58177. /** Points are incompatible because of their targets (vertex vs fragment) */
  58178. TargetIncompatible = 2
  58179. }
  58180. /**
  58181. * Defines the direction of a connection point
  58182. */
  58183. export enum NodeMaterialConnectionPointDirection {
  58184. /** Input */
  58185. Input = 0,
  58186. /** Output */
  58187. Output = 1
  58188. }
  58189. /**
  58190. * Defines a connection point for a block
  58191. */
  58192. export class NodeMaterialConnectionPoint {
  58193. /** @hidden */
  58194. _ownerBlock: NodeMaterialBlock;
  58195. /** @hidden */
  58196. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58197. private _endpoints;
  58198. private _associatedVariableName;
  58199. private _direction;
  58200. /** @hidden */
  58201. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58202. /** @hidden */
  58203. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58204. private _type;
  58205. /** @hidden */
  58206. _enforceAssociatedVariableName: boolean;
  58207. /** Gets the direction of the point */
  58208. get direction(): NodeMaterialConnectionPointDirection;
  58209. /**
  58210. * Gets or sets the additional types supported by this connection point
  58211. */
  58212. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58213. /**
  58214. * Gets or sets the additional types excluded by this connection point
  58215. */
  58216. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58217. /**
  58218. * Observable triggered when this point is connected
  58219. */
  58220. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58221. /**
  58222. * Gets or sets the associated variable name in the shader
  58223. */
  58224. get associatedVariableName(): string;
  58225. set associatedVariableName(value: string);
  58226. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58227. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58228. /**
  58229. * Gets or sets the connection point type (default is float)
  58230. */
  58231. get type(): NodeMaterialBlockConnectionPointTypes;
  58232. set type(value: NodeMaterialBlockConnectionPointTypes);
  58233. /**
  58234. * Gets or sets the connection point name
  58235. */
  58236. name: string;
  58237. /**
  58238. * Gets or sets a boolean indicating that this connection point can be omitted
  58239. */
  58240. isOptional: boolean;
  58241. /**
  58242. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58243. */
  58244. define: string;
  58245. /** @hidden */
  58246. _prioritizeVertex: boolean;
  58247. private _target;
  58248. /** Gets or sets the target of that connection point */
  58249. get target(): NodeMaterialBlockTargets;
  58250. set target(value: NodeMaterialBlockTargets);
  58251. /**
  58252. * Gets a boolean indicating that the current point is connected
  58253. */
  58254. get isConnected(): boolean;
  58255. /**
  58256. * Gets a boolean indicating that the current point is connected to an input block
  58257. */
  58258. get isConnectedToInputBlock(): boolean;
  58259. /**
  58260. * Gets a the connected input block (if any)
  58261. */
  58262. get connectInputBlock(): Nullable<InputBlock>;
  58263. /** Get the other side of the connection (if any) */
  58264. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58265. /** Get the block that owns this connection point */
  58266. get ownerBlock(): NodeMaterialBlock;
  58267. /** Get the block connected on the other side of this connection (if any) */
  58268. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58269. /** Get the block connected on the endpoints of this connection (if any) */
  58270. get connectedBlocks(): Array<NodeMaterialBlock>;
  58271. /** Gets the list of connected endpoints */
  58272. get endpoints(): NodeMaterialConnectionPoint[];
  58273. /** Gets a boolean indicating if that output point is connected to at least one input */
  58274. get hasEndpoints(): boolean;
  58275. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58276. get isConnectedInVertexShader(): boolean;
  58277. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58278. get isConnectedInFragmentShader(): boolean;
  58279. /**
  58280. * Creates a new connection point
  58281. * @param name defines the connection point name
  58282. * @param ownerBlock defines the block hosting this connection point
  58283. * @param direction defines the direction of the connection point
  58284. */
  58285. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58286. /**
  58287. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58288. * @returns the class name
  58289. */
  58290. getClassName(): string;
  58291. /**
  58292. * Gets a boolean indicating if the current point can be connected to another point
  58293. * @param connectionPoint defines the other connection point
  58294. * @returns a boolean
  58295. */
  58296. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58297. /**
  58298. * Gets a number indicating if the current point can be connected to another point
  58299. * @param connectionPoint defines the other connection point
  58300. * @returns a number defining the compatibility state
  58301. */
  58302. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58303. /**
  58304. * Connect this point to another connection point
  58305. * @param connectionPoint defines the other connection point
  58306. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58307. * @returns the current connection point
  58308. */
  58309. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58310. /**
  58311. * Disconnect this point from one of his endpoint
  58312. * @param endpoint defines the other connection point
  58313. * @returns the current connection point
  58314. */
  58315. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58316. /**
  58317. * Serializes this point in a JSON representation
  58318. * @returns the serialized point object
  58319. */
  58320. serialize(): any;
  58321. /**
  58322. * Release resources
  58323. */
  58324. dispose(): void;
  58325. }
  58326. }
  58327. declare module BABYLON {
  58328. /**
  58329. * Block used to add support for vertex skinning (bones)
  58330. */
  58331. export class BonesBlock extends NodeMaterialBlock {
  58332. /**
  58333. * Creates a new BonesBlock
  58334. * @param name defines the block name
  58335. */
  58336. constructor(name: string);
  58337. /**
  58338. * Initialize the block and prepare the context for build
  58339. * @param state defines the state that will be used for the build
  58340. */
  58341. initialize(state: NodeMaterialBuildState): void;
  58342. /**
  58343. * Gets the current class name
  58344. * @returns the class name
  58345. */
  58346. getClassName(): string;
  58347. /**
  58348. * Gets the matrix indices input component
  58349. */
  58350. get matricesIndices(): NodeMaterialConnectionPoint;
  58351. /**
  58352. * Gets the matrix weights input component
  58353. */
  58354. get matricesWeights(): NodeMaterialConnectionPoint;
  58355. /**
  58356. * Gets the extra matrix indices input component
  58357. */
  58358. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58359. /**
  58360. * Gets the extra matrix weights input component
  58361. */
  58362. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58363. /**
  58364. * Gets the world input component
  58365. */
  58366. get world(): NodeMaterialConnectionPoint;
  58367. /**
  58368. * Gets the output component
  58369. */
  58370. get output(): NodeMaterialConnectionPoint;
  58371. autoConfigure(material: NodeMaterial): void;
  58372. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58375. protected _buildBlock(state: NodeMaterialBuildState): this;
  58376. }
  58377. }
  58378. declare module BABYLON {
  58379. /**
  58380. * Block used to add support for instances
  58381. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58382. */
  58383. export class InstancesBlock extends NodeMaterialBlock {
  58384. /**
  58385. * Creates a new InstancesBlock
  58386. * @param name defines the block name
  58387. */
  58388. constructor(name: string);
  58389. /**
  58390. * Gets the current class name
  58391. * @returns the class name
  58392. */
  58393. getClassName(): string;
  58394. /**
  58395. * Gets the first world row input component
  58396. */
  58397. get world0(): NodeMaterialConnectionPoint;
  58398. /**
  58399. * Gets the second world row input component
  58400. */
  58401. get world1(): NodeMaterialConnectionPoint;
  58402. /**
  58403. * Gets the third world row input component
  58404. */
  58405. get world2(): NodeMaterialConnectionPoint;
  58406. /**
  58407. * Gets the forth world row input component
  58408. */
  58409. get world3(): NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the world input component
  58412. */
  58413. get world(): NodeMaterialConnectionPoint;
  58414. /**
  58415. * Gets the output component
  58416. */
  58417. get output(): NodeMaterialConnectionPoint;
  58418. /**
  58419. * Gets the isntanceID component
  58420. */
  58421. get instanceID(): NodeMaterialConnectionPoint;
  58422. autoConfigure(material: NodeMaterial): void;
  58423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58424. protected _buildBlock(state: NodeMaterialBuildState): this;
  58425. }
  58426. }
  58427. declare module BABYLON {
  58428. /**
  58429. * Block used to add morph targets support to vertex shader
  58430. */
  58431. export class MorphTargetsBlock extends NodeMaterialBlock {
  58432. private _repeatableContentAnchor;
  58433. /**
  58434. * Create a new MorphTargetsBlock
  58435. * @param name defines the block name
  58436. */
  58437. constructor(name: string);
  58438. /**
  58439. * Gets the current class name
  58440. * @returns the class name
  58441. */
  58442. getClassName(): string;
  58443. /**
  58444. * Gets the position input component
  58445. */
  58446. get position(): NodeMaterialConnectionPoint;
  58447. /**
  58448. * Gets the normal input component
  58449. */
  58450. get normal(): NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the tangent input component
  58453. */
  58454. get tangent(): NodeMaterialConnectionPoint;
  58455. /**
  58456. * Gets the tangent input component
  58457. */
  58458. get uv(): NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the position output component
  58461. */
  58462. get positionOutput(): NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the normal output component
  58465. */
  58466. get normalOutput(): NodeMaterialConnectionPoint;
  58467. /**
  58468. * Gets the tangent output component
  58469. */
  58470. get tangentOutput(): NodeMaterialConnectionPoint;
  58471. /**
  58472. * Gets the tangent output component
  58473. */
  58474. get uvOutput(): NodeMaterialConnectionPoint;
  58475. initialize(state: NodeMaterialBuildState): void;
  58476. autoConfigure(material: NodeMaterial): void;
  58477. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58479. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58480. protected _buildBlock(state: NodeMaterialBuildState): this;
  58481. }
  58482. }
  58483. declare module BABYLON {
  58484. /**
  58485. * Block used to get data information from a light
  58486. */
  58487. export class LightInformationBlock extends NodeMaterialBlock {
  58488. private _lightDataUniformName;
  58489. private _lightColorUniformName;
  58490. private _lightTypeDefineName;
  58491. /**
  58492. * Gets or sets the light associated with this block
  58493. */
  58494. light: Nullable<Light>;
  58495. /**
  58496. * Creates a new LightInformationBlock
  58497. * @param name defines the block name
  58498. */
  58499. constructor(name: string);
  58500. /**
  58501. * Gets the current class name
  58502. * @returns the class name
  58503. */
  58504. getClassName(): string;
  58505. /**
  58506. * Gets the world position input component
  58507. */
  58508. get worldPosition(): NodeMaterialConnectionPoint;
  58509. /**
  58510. * Gets the direction output component
  58511. */
  58512. get direction(): NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the direction output component
  58515. */
  58516. get color(): NodeMaterialConnectionPoint;
  58517. /**
  58518. * Gets the direction output component
  58519. */
  58520. get intensity(): NodeMaterialConnectionPoint;
  58521. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58523. protected _buildBlock(state: NodeMaterialBuildState): this;
  58524. serialize(): any;
  58525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58526. }
  58527. }
  58528. declare module BABYLON {
  58529. /**
  58530. * Block used to add image processing support to fragment shader
  58531. */
  58532. export class ImageProcessingBlock extends NodeMaterialBlock {
  58533. /**
  58534. * Create a new ImageProcessingBlock
  58535. * @param name defines the block name
  58536. */
  58537. constructor(name: string);
  58538. /**
  58539. * Gets the current class name
  58540. * @returns the class name
  58541. */
  58542. getClassName(): string;
  58543. /**
  58544. * Gets the color input component
  58545. */
  58546. get color(): NodeMaterialConnectionPoint;
  58547. /**
  58548. * Gets the output component
  58549. */
  58550. get output(): NodeMaterialConnectionPoint;
  58551. /**
  58552. * Initialize the block and prepare the context for build
  58553. * @param state defines the state that will be used for the build
  58554. */
  58555. initialize(state: NodeMaterialBuildState): void;
  58556. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58559. protected _buildBlock(state: NodeMaterialBuildState): this;
  58560. }
  58561. }
  58562. declare module BABYLON {
  58563. /**
  58564. * Block used to pertub normals based on a normal map
  58565. */
  58566. export class PerturbNormalBlock extends NodeMaterialBlock {
  58567. private _tangentSpaceParameterName;
  58568. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58569. invertX: boolean;
  58570. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58571. invertY: boolean;
  58572. /**
  58573. * Create a new PerturbNormalBlock
  58574. * @param name defines the block name
  58575. */
  58576. constructor(name: string);
  58577. /**
  58578. * Gets the current class name
  58579. * @returns the class name
  58580. */
  58581. getClassName(): string;
  58582. /**
  58583. * Gets the world position input component
  58584. */
  58585. get worldPosition(): NodeMaterialConnectionPoint;
  58586. /**
  58587. * Gets the world normal input component
  58588. */
  58589. get worldNormal(): NodeMaterialConnectionPoint;
  58590. /**
  58591. * Gets the world tangent input component
  58592. */
  58593. get worldTangent(): NodeMaterialConnectionPoint;
  58594. /**
  58595. * Gets the uv input component
  58596. */
  58597. get uv(): NodeMaterialConnectionPoint;
  58598. /**
  58599. * Gets the normal map color input component
  58600. */
  58601. get normalMapColor(): NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the strength input component
  58604. */
  58605. get strength(): NodeMaterialConnectionPoint;
  58606. /**
  58607. * Gets the output component
  58608. */
  58609. get output(): NodeMaterialConnectionPoint;
  58610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58611. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58612. autoConfigure(material: NodeMaterial): void;
  58613. protected _buildBlock(state: NodeMaterialBuildState): this;
  58614. protected _dumpPropertiesCode(): string;
  58615. serialize(): any;
  58616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58617. }
  58618. }
  58619. declare module BABYLON {
  58620. /**
  58621. * Block used to discard a pixel if a value is smaller than a cutoff
  58622. */
  58623. export class DiscardBlock extends NodeMaterialBlock {
  58624. /**
  58625. * Create a new DiscardBlock
  58626. * @param name defines the block name
  58627. */
  58628. constructor(name: string);
  58629. /**
  58630. * Gets the current class name
  58631. * @returns the class name
  58632. */
  58633. getClassName(): string;
  58634. /**
  58635. * Gets the color input component
  58636. */
  58637. get value(): NodeMaterialConnectionPoint;
  58638. /**
  58639. * Gets the cutoff input component
  58640. */
  58641. get cutoff(): NodeMaterialConnectionPoint;
  58642. protected _buildBlock(state: NodeMaterialBuildState): this;
  58643. }
  58644. }
  58645. declare module BABYLON {
  58646. /**
  58647. * Block used to test if the fragment shader is front facing
  58648. */
  58649. export class FrontFacingBlock extends NodeMaterialBlock {
  58650. /**
  58651. * Creates a new FrontFacingBlock
  58652. * @param name defines the block name
  58653. */
  58654. constructor(name: string);
  58655. /**
  58656. * Gets the current class name
  58657. * @returns the class name
  58658. */
  58659. getClassName(): string;
  58660. /**
  58661. * Gets the output component
  58662. */
  58663. get output(): NodeMaterialConnectionPoint;
  58664. protected _buildBlock(state: NodeMaterialBuildState): this;
  58665. }
  58666. }
  58667. declare module BABYLON {
  58668. /**
  58669. * Block used to get the derivative value on x and y of a given input
  58670. */
  58671. export class DerivativeBlock extends NodeMaterialBlock {
  58672. /**
  58673. * Create a new DerivativeBlock
  58674. * @param name defines the block name
  58675. */
  58676. constructor(name: string);
  58677. /**
  58678. * Gets the current class name
  58679. * @returns the class name
  58680. */
  58681. getClassName(): string;
  58682. /**
  58683. * Gets the input component
  58684. */
  58685. get input(): NodeMaterialConnectionPoint;
  58686. /**
  58687. * Gets the derivative output on x
  58688. */
  58689. get dx(): NodeMaterialConnectionPoint;
  58690. /**
  58691. * Gets the derivative output on y
  58692. */
  58693. get dy(): NodeMaterialConnectionPoint;
  58694. protected _buildBlock(state: NodeMaterialBuildState): this;
  58695. }
  58696. }
  58697. declare module BABYLON {
  58698. /**
  58699. * Block used to add support for scene fog
  58700. */
  58701. export class FogBlock extends NodeMaterialBlock {
  58702. private _fogDistanceName;
  58703. private _fogParameters;
  58704. /**
  58705. * Create a new FogBlock
  58706. * @param name defines the block name
  58707. */
  58708. constructor(name: string);
  58709. /**
  58710. * Gets the current class name
  58711. * @returns the class name
  58712. */
  58713. getClassName(): string;
  58714. /**
  58715. * Gets the world position input component
  58716. */
  58717. get worldPosition(): NodeMaterialConnectionPoint;
  58718. /**
  58719. * Gets the view input component
  58720. */
  58721. get view(): NodeMaterialConnectionPoint;
  58722. /**
  58723. * Gets the color input component
  58724. */
  58725. get input(): NodeMaterialConnectionPoint;
  58726. /**
  58727. * Gets the fog color input component
  58728. */
  58729. get fogColor(): NodeMaterialConnectionPoint;
  58730. /**
  58731. * Gets the output component
  58732. */
  58733. get output(): NodeMaterialConnectionPoint;
  58734. autoConfigure(material: NodeMaterial): void;
  58735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58736. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58737. protected _buildBlock(state: NodeMaterialBuildState): this;
  58738. }
  58739. }
  58740. declare module BABYLON {
  58741. /**
  58742. * Block used to add light in the fragment shader
  58743. */
  58744. export class LightBlock extends NodeMaterialBlock {
  58745. private _lightId;
  58746. /**
  58747. * Gets or sets the light associated with this block
  58748. */
  58749. light: Nullable<Light>;
  58750. /**
  58751. * Create a new LightBlock
  58752. * @param name defines the block name
  58753. */
  58754. constructor(name: string);
  58755. /**
  58756. * Gets the current class name
  58757. * @returns the class name
  58758. */
  58759. getClassName(): string;
  58760. /**
  58761. * Gets the world position input component
  58762. */
  58763. get worldPosition(): NodeMaterialConnectionPoint;
  58764. /**
  58765. * Gets the world normal input component
  58766. */
  58767. get worldNormal(): NodeMaterialConnectionPoint;
  58768. /**
  58769. * Gets the camera (or eye) position component
  58770. */
  58771. get cameraPosition(): NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the glossiness component
  58774. */
  58775. get glossiness(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the glossinness power component
  58778. */
  58779. get glossPower(): NodeMaterialConnectionPoint;
  58780. /**
  58781. * Gets the diffuse color component
  58782. */
  58783. get diffuseColor(): NodeMaterialConnectionPoint;
  58784. /**
  58785. * Gets the specular color component
  58786. */
  58787. get specularColor(): NodeMaterialConnectionPoint;
  58788. /**
  58789. * Gets the diffuse output component
  58790. */
  58791. get diffuseOutput(): NodeMaterialConnectionPoint;
  58792. /**
  58793. * Gets the specular output component
  58794. */
  58795. get specularOutput(): NodeMaterialConnectionPoint;
  58796. /**
  58797. * Gets the shadow output component
  58798. */
  58799. get shadow(): NodeMaterialConnectionPoint;
  58800. autoConfigure(material: NodeMaterial): void;
  58801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58802. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58803. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58804. private _injectVertexCode;
  58805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58806. serialize(): any;
  58807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58808. }
  58809. }
  58810. declare module BABYLON {
  58811. /**
  58812. * Block used to multiply 2 values
  58813. */
  58814. export class MultiplyBlock extends NodeMaterialBlock {
  58815. /**
  58816. * Creates a new MultiplyBlock
  58817. * @param name defines the block name
  58818. */
  58819. constructor(name: string);
  58820. /**
  58821. * Gets the current class name
  58822. * @returns the class name
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Gets the left operand input component
  58827. */
  58828. get left(): NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the right operand input component
  58831. */
  58832. get right(): NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the output component
  58835. */
  58836. get output(): NodeMaterialConnectionPoint;
  58837. protected _buildBlock(state: NodeMaterialBuildState): this;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Block used to add 2 vectors
  58843. */
  58844. export class AddBlock extends NodeMaterialBlock {
  58845. /**
  58846. * Creates a new AddBlock
  58847. * @param name defines the block name
  58848. */
  58849. constructor(name: string);
  58850. /**
  58851. * Gets the current class name
  58852. * @returns the class name
  58853. */
  58854. getClassName(): string;
  58855. /**
  58856. * Gets the left operand input component
  58857. */
  58858. get left(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the right operand input component
  58861. */
  58862. get right(): NodeMaterialConnectionPoint;
  58863. /**
  58864. * Gets the output component
  58865. */
  58866. get output(): NodeMaterialConnectionPoint;
  58867. protected _buildBlock(state: NodeMaterialBuildState): this;
  58868. }
  58869. }
  58870. declare module BABYLON {
  58871. /**
  58872. * Block used to scale a vector by a float
  58873. */
  58874. export class ScaleBlock extends NodeMaterialBlock {
  58875. /**
  58876. * Creates a new ScaleBlock
  58877. * @param name defines the block name
  58878. */
  58879. constructor(name: string);
  58880. /**
  58881. * Gets the current class name
  58882. * @returns the class name
  58883. */
  58884. getClassName(): string;
  58885. /**
  58886. * Gets the input component
  58887. */
  58888. get input(): NodeMaterialConnectionPoint;
  58889. /**
  58890. * Gets the factor input component
  58891. */
  58892. get factor(): NodeMaterialConnectionPoint;
  58893. /**
  58894. * Gets the output component
  58895. */
  58896. get output(): NodeMaterialConnectionPoint;
  58897. protected _buildBlock(state: NodeMaterialBuildState): this;
  58898. }
  58899. }
  58900. declare module BABYLON {
  58901. /**
  58902. * Block used to clamp a float
  58903. */
  58904. export class ClampBlock extends NodeMaterialBlock {
  58905. /** Gets or sets the minimum range */
  58906. minimum: number;
  58907. /** Gets or sets the maximum range */
  58908. maximum: number;
  58909. /**
  58910. * Creates a new ClampBlock
  58911. * @param name defines the block name
  58912. */
  58913. constructor(name: string);
  58914. /**
  58915. * Gets the current class name
  58916. * @returns the class name
  58917. */
  58918. getClassName(): string;
  58919. /**
  58920. * Gets the value input component
  58921. */
  58922. get value(): NodeMaterialConnectionPoint;
  58923. /**
  58924. * Gets the output component
  58925. */
  58926. get output(): NodeMaterialConnectionPoint;
  58927. protected _buildBlock(state: NodeMaterialBuildState): this;
  58928. protected _dumpPropertiesCode(): string;
  58929. serialize(): any;
  58930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58931. }
  58932. }
  58933. declare module BABYLON {
  58934. /**
  58935. * Block used to apply a cross product between 2 vectors
  58936. */
  58937. export class CrossBlock extends NodeMaterialBlock {
  58938. /**
  58939. * Creates a new CrossBlock
  58940. * @param name defines the block name
  58941. */
  58942. constructor(name: string);
  58943. /**
  58944. * Gets the current class name
  58945. * @returns the class name
  58946. */
  58947. getClassName(): string;
  58948. /**
  58949. * Gets the left operand input component
  58950. */
  58951. get left(): NodeMaterialConnectionPoint;
  58952. /**
  58953. * Gets the right operand input component
  58954. */
  58955. get right(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the output component
  58958. */
  58959. get output(): NodeMaterialConnectionPoint;
  58960. protected _buildBlock(state: NodeMaterialBuildState): this;
  58961. }
  58962. }
  58963. declare module BABYLON {
  58964. /**
  58965. * Block used to apply a dot product between 2 vectors
  58966. */
  58967. export class DotBlock extends NodeMaterialBlock {
  58968. /**
  58969. * Creates a new DotBlock
  58970. * @param name defines the block name
  58971. */
  58972. constructor(name: string);
  58973. /**
  58974. * Gets the current class name
  58975. * @returns the class name
  58976. */
  58977. getClassName(): string;
  58978. /**
  58979. * Gets the left operand input component
  58980. */
  58981. get left(): NodeMaterialConnectionPoint;
  58982. /**
  58983. * Gets the right operand input component
  58984. */
  58985. get right(): NodeMaterialConnectionPoint;
  58986. /**
  58987. * Gets the output component
  58988. */
  58989. get output(): NodeMaterialConnectionPoint;
  58990. protected _buildBlock(state: NodeMaterialBuildState): this;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * Block used to remap a float from a range to a new one
  58996. */
  58997. export class RemapBlock extends NodeMaterialBlock {
  58998. /**
  58999. * Gets or sets the source range
  59000. */
  59001. sourceRange: Vector2;
  59002. /**
  59003. * Gets or sets the target range
  59004. */
  59005. targetRange: Vector2;
  59006. /**
  59007. * Creates a new RemapBlock
  59008. * @param name defines the block name
  59009. */
  59010. constructor(name: string);
  59011. /**
  59012. * Gets the current class name
  59013. * @returns the class name
  59014. */
  59015. getClassName(): string;
  59016. /**
  59017. * Gets the input component
  59018. */
  59019. get input(): NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the source min input component
  59022. */
  59023. get sourceMin(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the source max input component
  59026. */
  59027. get sourceMax(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the target min input component
  59030. */
  59031. get targetMin(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the target max input component
  59034. */
  59035. get targetMax(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the output component
  59038. */
  59039. get output(): NodeMaterialConnectionPoint;
  59040. protected _buildBlock(state: NodeMaterialBuildState): this;
  59041. protected _dumpPropertiesCode(): string;
  59042. serialize(): any;
  59043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59044. }
  59045. }
  59046. declare module BABYLON {
  59047. /**
  59048. * Block used to normalize a vector
  59049. */
  59050. export class NormalizeBlock extends NodeMaterialBlock {
  59051. /**
  59052. * Creates a new NormalizeBlock
  59053. * @param name defines the block name
  59054. */
  59055. constructor(name: string);
  59056. /**
  59057. * Gets the current class name
  59058. * @returns the class name
  59059. */
  59060. getClassName(): string;
  59061. /**
  59062. * Gets the input component
  59063. */
  59064. get input(): NodeMaterialConnectionPoint;
  59065. /**
  59066. * Gets the output component
  59067. */
  59068. get output(): NodeMaterialConnectionPoint;
  59069. protected _buildBlock(state: NodeMaterialBuildState): this;
  59070. }
  59071. }
  59072. declare module BABYLON {
  59073. /**
  59074. * Operations supported by the Trigonometry block
  59075. */
  59076. export enum TrigonometryBlockOperations {
  59077. /** Cos */
  59078. Cos = 0,
  59079. /** Sin */
  59080. Sin = 1,
  59081. /** Abs */
  59082. Abs = 2,
  59083. /** Exp */
  59084. Exp = 3,
  59085. /** Exp2 */
  59086. Exp2 = 4,
  59087. /** Round */
  59088. Round = 5,
  59089. /** Floor */
  59090. Floor = 6,
  59091. /** Ceiling */
  59092. Ceiling = 7,
  59093. /** Square root */
  59094. Sqrt = 8,
  59095. /** Log */
  59096. Log = 9,
  59097. /** Tangent */
  59098. Tan = 10,
  59099. /** Arc tangent */
  59100. ArcTan = 11,
  59101. /** Arc cosinus */
  59102. ArcCos = 12,
  59103. /** Arc sinus */
  59104. ArcSin = 13,
  59105. /** Fraction */
  59106. Fract = 14,
  59107. /** Sign */
  59108. Sign = 15,
  59109. /** To radians (from degrees) */
  59110. Radians = 16,
  59111. /** To degrees (from radians) */
  59112. Degrees = 17
  59113. }
  59114. /**
  59115. * Block used to apply trigonometry operation to floats
  59116. */
  59117. export class TrigonometryBlock extends NodeMaterialBlock {
  59118. /**
  59119. * Gets or sets the operation applied by the block
  59120. */
  59121. operation: TrigonometryBlockOperations;
  59122. /**
  59123. * Creates a new TrigonometryBlock
  59124. * @param name defines the block name
  59125. */
  59126. constructor(name: string);
  59127. /**
  59128. * Gets the current class name
  59129. * @returns the class name
  59130. */
  59131. getClassName(): string;
  59132. /**
  59133. * Gets the input component
  59134. */
  59135. get input(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the output component
  59138. */
  59139. get output(): NodeMaterialConnectionPoint;
  59140. protected _buildBlock(state: NodeMaterialBuildState): this;
  59141. serialize(): any;
  59142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59143. protected _dumpPropertiesCode(): string;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /**
  59148. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59149. */
  59150. export class ColorMergerBlock extends NodeMaterialBlock {
  59151. /**
  59152. * Create a new ColorMergerBlock
  59153. * @param name defines the block name
  59154. */
  59155. constructor(name: string);
  59156. /**
  59157. * Gets the current class name
  59158. * @returns the class name
  59159. */
  59160. getClassName(): string;
  59161. /**
  59162. * Gets the rgb component (input)
  59163. */
  59164. get rgbIn(): NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the r component (input)
  59167. */
  59168. get r(): NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the g component (input)
  59171. */
  59172. get g(): NodeMaterialConnectionPoint;
  59173. /**
  59174. * Gets the b component (input)
  59175. */
  59176. get b(): NodeMaterialConnectionPoint;
  59177. /**
  59178. * Gets the a component (input)
  59179. */
  59180. get a(): NodeMaterialConnectionPoint;
  59181. /**
  59182. * Gets the rgba component (output)
  59183. */
  59184. get rgba(): NodeMaterialConnectionPoint;
  59185. /**
  59186. * Gets the rgb component (output)
  59187. */
  59188. get rgbOut(): NodeMaterialConnectionPoint;
  59189. /**
  59190. * Gets the rgb component (output)
  59191. * @deprecated Please use rgbOut instead.
  59192. */
  59193. get rgb(): NodeMaterialConnectionPoint;
  59194. protected _buildBlock(state: NodeMaterialBuildState): this;
  59195. }
  59196. }
  59197. declare module BABYLON {
  59198. /**
  59199. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59200. */
  59201. export class VectorMergerBlock extends NodeMaterialBlock {
  59202. /**
  59203. * Create a new VectorMergerBlock
  59204. * @param name defines the block name
  59205. */
  59206. constructor(name: string);
  59207. /**
  59208. * Gets the current class name
  59209. * @returns the class name
  59210. */
  59211. getClassName(): string;
  59212. /**
  59213. * Gets the xyz component (input)
  59214. */
  59215. get xyzIn(): NodeMaterialConnectionPoint;
  59216. /**
  59217. * Gets the xy component (input)
  59218. */
  59219. get xyIn(): NodeMaterialConnectionPoint;
  59220. /**
  59221. * Gets the x component (input)
  59222. */
  59223. get x(): NodeMaterialConnectionPoint;
  59224. /**
  59225. * Gets the y component (input)
  59226. */
  59227. get y(): NodeMaterialConnectionPoint;
  59228. /**
  59229. * Gets the z component (input)
  59230. */
  59231. get z(): NodeMaterialConnectionPoint;
  59232. /**
  59233. * Gets the w component (input)
  59234. */
  59235. get w(): NodeMaterialConnectionPoint;
  59236. /**
  59237. * Gets the xyzw component (output)
  59238. */
  59239. get xyzw(): NodeMaterialConnectionPoint;
  59240. /**
  59241. * Gets the xyz component (output)
  59242. */
  59243. get xyzOut(): NodeMaterialConnectionPoint;
  59244. /**
  59245. * Gets the xy component (output)
  59246. */
  59247. get xyOut(): NodeMaterialConnectionPoint;
  59248. /**
  59249. * Gets the xy component (output)
  59250. * @deprecated Please use xyOut instead.
  59251. */
  59252. get xy(): NodeMaterialConnectionPoint;
  59253. /**
  59254. * Gets the xyz component (output)
  59255. * @deprecated Please use xyzOut instead.
  59256. */
  59257. get xyz(): NodeMaterialConnectionPoint;
  59258. protected _buildBlock(state: NodeMaterialBuildState): this;
  59259. }
  59260. }
  59261. declare module BABYLON {
  59262. /**
  59263. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59264. */
  59265. export class ColorSplitterBlock extends NodeMaterialBlock {
  59266. /**
  59267. * Create a new ColorSplitterBlock
  59268. * @param name defines the block name
  59269. */
  59270. constructor(name: string);
  59271. /**
  59272. * Gets the current class name
  59273. * @returns the class name
  59274. */
  59275. getClassName(): string;
  59276. /**
  59277. * Gets the rgba component (input)
  59278. */
  59279. get rgba(): NodeMaterialConnectionPoint;
  59280. /**
  59281. * Gets the rgb component (input)
  59282. */
  59283. get rgbIn(): NodeMaterialConnectionPoint;
  59284. /**
  59285. * Gets the rgb component (output)
  59286. */
  59287. get rgbOut(): NodeMaterialConnectionPoint;
  59288. /**
  59289. * Gets the r component (output)
  59290. */
  59291. get r(): NodeMaterialConnectionPoint;
  59292. /**
  59293. * Gets the g component (output)
  59294. */
  59295. get g(): NodeMaterialConnectionPoint;
  59296. /**
  59297. * Gets the b component (output)
  59298. */
  59299. get b(): NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the a component (output)
  59302. */
  59303. get a(): NodeMaterialConnectionPoint;
  59304. protected _inputRename(name: string): string;
  59305. protected _outputRename(name: string): string;
  59306. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59307. }
  59308. }
  59309. declare module BABYLON {
  59310. /**
  59311. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59312. */
  59313. export class VectorSplitterBlock extends NodeMaterialBlock {
  59314. /**
  59315. * Create a new VectorSplitterBlock
  59316. * @param name defines the block name
  59317. */
  59318. constructor(name: string);
  59319. /**
  59320. * Gets the current class name
  59321. * @returns the class name
  59322. */
  59323. getClassName(): string;
  59324. /**
  59325. * Gets the xyzw component (input)
  59326. */
  59327. get xyzw(): NodeMaterialConnectionPoint;
  59328. /**
  59329. * Gets the xyz component (input)
  59330. */
  59331. get xyzIn(): NodeMaterialConnectionPoint;
  59332. /**
  59333. * Gets the xy component (input)
  59334. */
  59335. get xyIn(): NodeMaterialConnectionPoint;
  59336. /**
  59337. * Gets the xyz component (output)
  59338. */
  59339. get xyzOut(): NodeMaterialConnectionPoint;
  59340. /**
  59341. * Gets the xy component (output)
  59342. */
  59343. get xyOut(): NodeMaterialConnectionPoint;
  59344. /**
  59345. * Gets the x component (output)
  59346. */
  59347. get x(): NodeMaterialConnectionPoint;
  59348. /**
  59349. * Gets the y component (output)
  59350. */
  59351. get y(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the z component (output)
  59354. */
  59355. get z(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the w component (output)
  59358. */
  59359. get w(): NodeMaterialConnectionPoint;
  59360. protected _inputRename(name: string): string;
  59361. protected _outputRename(name: string): string;
  59362. protected _buildBlock(state: NodeMaterialBuildState): this;
  59363. }
  59364. }
  59365. declare module BABYLON {
  59366. /**
  59367. * Block used to lerp between 2 values
  59368. */
  59369. export class LerpBlock extends NodeMaterialBlock {
  59370. /**
  59371. * Creates a new LerpBlock
  59372. * @param name defines the block name
  59373. */
  59374. constructor(name: string);
  59375. /**
  59376. * Gets the current class name
  59377. * @returns the class name
  59378. */
  59379. getClassName(): string;
  59380. /**
  59381. * Gets the left operand input component
  59382. */
  59383. get left(): NodeMaterialConnectionPoint;
  59384. /**
  59385. * Gets the right operand input component
  59386. */
  59387. get right(): NodeMaterialConnectionPoint;
  59388. /**
  59389. * Gets the gradient operand input component
  59390. */
  59391. get gradient(): NodeMaterialConnectionPoint;
  59392. /**
  59393. * Gets the output component
  59394. */
  59395. get output(): NodeMaterialConnectionPoint;
  59396. protected _buildBlock(state: NodeMaterialBuildState): this;
  59397. }
  59398. }
  59399. declare module BABYLON {
  59400. /**
  59401. * Block used to divide 2 vectors
  59402. */
  59403. export class DivideBlock extends NodeMaterialBlock {
  59404. /**
  59405. * Creates a new DivideBlock
  59406. * @param name defines the block name
  59407. */
  59408. constructor(name: string);
  59409. /**
  59410. * Gets the current class name
  59411. * @returns the class name
  59412. */
  59413. getClassName(): string;
  59414. /**
  59415. * Gets the left operand input component
  59416. */
  59417. get left(): NodeMaterialConnectionPoint;
  59418. /**
  59419. * Gets the right operand input component
  59420. */
  59421. get right(): NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the output component
  59424. */
  59425. get output(): NodeMaterialConnectionPoint;
  59426. protected _buildBlock(state: NodeMaterialBuildState): this;
  59427. }
  59428. }
  59429. declare module BABYLON {
  59430. /**
  59431. * Block used to subtract 2 vectors
  59432. */
  59433. export class SubtractBlock extends NodeMaterialBlock {
  59434. /**
  59435. * Creates a new SubtractBlock
  59436. * @param name defines the block name
  59437. */
  59438. constructor(name: string);
  59439. /**
  59440. * Gets the current class name
  59441. * @returns the class name
  59442. */
  59443. getClassName(): string;
  59444. /**
  59445. * Gets the left operand input component
  59446. */
  59447. get left(): NodeMaterialConnectionPoint;
  59448. /**
  59449. * Gets the right operand input component
  59450. */
  59451. get right(): NodeMaterialConnectionPoint;
  59452. /**
  59453. * Gets the output component
  59454. */
  59455. get output(): NodeMaterialConnectionPoint;
  59456. protected _buildBlock(state: NodeMaterialBuildState): this;
  59457. }
  59458. }
  59459. declare module BABYLON {
  59460. /**
  59461. * Block used to step a value
  59462. */
  59463. export class StepBlock extends NodeMaterialBlock {
  59464. /**
  59465. * Creates a new StepBlock
  59466. * @param name defines the block name
  59467. */
  59468. constructor(name: string);
  59469. /**
  59470. * Gets the current class name
  59471. * @returns the class name
  59472. */
  59473. getClassName(): string;
  59474. /**
  59475. * Gets the value operand input component
  59476. */
  59477. get value(): NodeMaterialConnectionPoint;
  59478. /**
  59479. * Gets the edge operand input component
  59480. */
  59481. get edge(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the output component
  59484. */
  59485. get output(): NodeMaterialConnectionPoint;
  59486. protected _buildBlock(state: NodeMaterialBuildState): this;
  59487. }
  59488. }
  59489. declare module BABYLON {
  59490. /**
  59491. * Block used to get the opposite (1 - x) of a value
  59492. */
  59493. export class OneMinusBlock extends NodeMaterialBlock {
  59494. /**
  59495. * Creates a new OneMinusBlock
  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 input component
  59506. */
  59507. get input(): NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the output component
  59510. */
  59511. get output(): NodeMaterialConnectionPoint;
  59512. protected _buildBlock(state: NodeMaterialBuildState): this;
  59513. }
  59514. }
  59515. declare module BABYLON {
  59516. /**
  59517. * Block used to get the view direction
  59518. */
  59519. export class ViewDirectionBlock extends NodeMaterialBlock {
  59520. /**
  59521. * Creates a new ViewDirectionBlock
  59522. * @param name defines the block name
  59523. */
  59524. constructor(name: string);
  59525. /**
  59526. * Gets the current class name
  59527. * @returns the class name
  59528. */
  59529. getClassName(): string;
  59530. /**
  59531. * Gets the world position component
  59532. */
  59533. get worldPosition(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the camera position component
  59536. */
  59537. get cameraPosition(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the output component
  59540. */
  59541. get output(): NodeMaterialConnectionPoint;
  59542. autoConfigure(material: NodeMaterial): void;
  59543. protected _buildBlock(state: NodeMaterialBuildState): this;
  59544. }
  59545. }
  59546. declare module BABYLON {
  59547. /**
  59548. * Block used to compute fresnel value
  59549. */
  59550. export class FresnelBlock extends NodeMaterialBlock {
  59551. /**
  59552. * Create a new FresnelBlock
  59553. * @param name defines the block name
  59554. */
  59555. constructor(name: string);
  59556. /**
  59557. * Gets the current class name
  59558. * @returns the class name
  59559. */
  59560. getClassName(): string;
  59561. /**
  59562. * Gets the world normal input component
  59563. */
  59564. get worldNormal(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the view direction input component
  59567. */
  59568. get viewDirection(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the bias input component
  59571. */
  59572. get bias(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the camera (or eye) position component
  59575. */
  59576. get power(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the fresnel output component
  59579. */
  59580. get fresnel(): NodeMaterialConnectionPoint;
  59581. autoConfigure(material: NodeMaterial): void;
  59582. protected _buildBlock(state: NodeMaterialBuildState): this;
  59583. }
  59584. }
  59585. declare module BABYLON {
  59586. /**
  59587. * Block used to get the max of 2 values
  59588. */
  59589. export class MaxBlock extends NodeMaterialBlock {
  59590. /**
  59591. * Creates a new MaxBlock
  59592. * @param name defines the block name
  59593. */
  59594. constructor(name: string);
  59595. /**
  59596. * Gets the current class name
  59597. * @returns the class name
  59598. */
  59599. getClassName(): string;
  59600. /**
  59601. * Gets the left operand input component
  59602. */
  59603. get left(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the right operand input component
  59606. */
  59607. get right(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the output component
  59610. */
  59611. get output(): NodeMaterialConnectionPoint;
  59612. protected _buildBlock(state: NodeMaterialBuildState): this;
  59613. }
  59614. }
  59615. declare module BABYLON {
  59616. /**
  59617. * Block used to get the min of 2 values
  59618. */
  59619. export class MinBlock extends NodeMaterialBlock {
  59620. /**
  59621. * Creates a new MinBlock
  59622. * @param name defines the block name
  59623. */
  59624. constructor(name: string);
  59625. /**
  59626. * Gets the current class name
  59627. * @returns the class name
  59628. */
  59629. getClassName(): string;
  59630. /**
  59631. * Gets the left operand input component
  59632. */
  59633. get left(): NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the right operand input component
  59636. */
  59637. get right(): NodeMaterialConnectionPoint;
  59638. /**
  59639. * Gets the output component
  59640. */
  59641. get output(): NodeMaterialConnectionPoint;
  59642. protected _buildBlock(state: NodeMaterialBuildState): this;
  59643. }
  59644. }
  59645. declare module BABYLON {
  59646. /**
  59647. * Block used to get the distance between 2 values
  59648. */
  59649. export class DistanceBlock extends NodeMaterialBlock {
  59650. /**
  59651. * Creates a new DistanceBlock
  59652. * @param name defines the block name
  59653. */
  59654. constructor(name: string);
  59655. /**
  59656. * Gets the current class name
  59657. * @returns the class name
  59658. */
  59659. getClassName(): string;
  59660. /**
  59661. * Gets the left operand input component
  59662. */
  59663. get left(): NodeMaterialConnectionPoint;
  59664. /**
  59665. * Gets the right operand input component
  59666. */
  59667. get right(): NodeMaterialConnectionPoint;
  59668. /**
  59669. * Gets the output component
  59670. */
  59671. get output(): NodeMaterialConnectionPoint;
  59672. protected _buildBlock(state: NodeMaterialBuildState): this;
  59673. }
  59674. }
  59675. declare module BABYLON {
  59676. /**
  59677. * Block used to get the length of a vector
  59678. */
  59679. export class LengthBlock extends NodeMaterialBlock {
  59680. /**
  59681. * Creates a new LengthBlock
  59682. * @param name defines the block name
  59683. */
  59684. constructor(name: string);
  59685. /**
  59686. * Gets the current class name
  59687. * @returns the class name
  59688. */
  59689. getClassName(): string;
  59690. /**
  59691. * Gets the value input component
  59692. */
  59693. get value(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the output component
  59696. */
  59697. get output(): NodeMaterialConnectionPoint;
  59698. protected _buildBlock(state: NodeMaterialBuildState): this;
  59699. }
  59700. }
  59701. declare module BABYLON {
  59702. /**
  59703. * Block used to get negative version of a value (i.e. x * -1)
  59704. */
  59705. export class NegateBlock extends NodeMaterialBlock {
  59706. /**
  59707. * Creates a new NegateBlock
  59708. * @param name defines the block name
  59709. */
  59710. constructor(name: string);
  59711. /**
  59712. * Gets the current class name
  59713. * @returns the class name
  59714. */
  59715. getClassName(): string;
  59716. /**
  59717. * Gets the value input component
  59718. */
  59719. get value(): NodeMaterialConnectionPoint;
  59720. /**
  59721. * Gets the output component
  59722. */
  59723. get output(): NodeMaterialConnectionPoint;
  59724. protected _buildBlock(state: NodeMaterialBuildState): this;
  59725. }
  59726. }
  59727. declare module BABYLON {
  59728. /**
  59729. * Block used to get the value of the first parameter raised to the power of the second
  59730. */
  59731. export class PowBlock extends NodeMaterialBlock {
  59732. /**
  59733. * Creates a new PowBlock
  59734. * @param name defines the block name
  59735. */
  59736. constructor(name: string);
  59737. /**
  59738. * Gets the current class name
  59739. * @returns the class name
  59740. */
  59741. getClassName(): string;
  59742. /**
  59743. * Gets the value operand input component
  59744. */
  59745. get value(): NodeMaterialConnectionPoint;
  59746. /**
  59747. * Gets the power operand input component
  59748. */
  59749. get power(): NodeMaterialConnectionPoint;
  59750. /**
  59751. * Gets the output component
  59752. */
  59753. get output(): NodeMaterialConnectionPoint;
  59754. protected _buildBlock(state: NodeMaterialBuildState): this;
  59755. }
  59756. }
  59757. declare module BABYLON {
  59758. /**
  59759. * Block used to get a random number
  59760. */
  59761. export class RandomNumberBlock extends NodeMaterialBlock {
  59762. /**
  59763. * Creates a new RandomNumberBlock
  59764. * @param name defines the block name
  59765. */
  59766. constructor(name: string);
  59767. /**
  59768. * Gets the current class name
  59769. * @returns the class name
  59770. */
  59771. getClassName(): string;
  59772. /**
  59773. * Gets the seed input component
  59774. */
  59775. get seed(): NodeMaterialConnectionPoint;
  59776. /**
  59777. * Gets the output component
  59778. */
  59779. get output(): NodeMaterialConnectionPoint;
  59780. protected _buildBlock(state: NodeMaterialBuildState): this;
  59781. }
  59782. }
  59783. declare module BABYLON {
  59784. /**
  59785. * Block used to compute arc tangent of 2 values
  59786. */
  59787. export class ArcTan2Block extends NodeMaterialBlock {
  59788. /**
  59789. * Creates a new ArcTan2Block
  59790. * @param name defines the block name
  59791. */
  59792. constructor(name: string);
  59793. /**
  59794. * Gets the current class name
  59795. * @returns the class name
  59796. */
  59797. getClassName(): string;
  59798. /**
  59799. * Gets the x operand input component
  59800. */
  59801. get x(): NodeMaterialConnectionPoint;
  59802. /**
  59803. * Gets the y operand input component
  59804. */
  59805. get y(): NodeMaterialConnectionPoint;
  59806. /**
  59807. * Gets the output component
  59808. */
  59809. get output(): NodeMaterialConnectionPoint;
  59810. protected _buildBlock(state: NodeMaterialBuildState): this;
  59811. }
  59812. }
  59813. declare module BABYLON {
  59814. /**
  59815. * Block used to smooth step a value
  59816. */
  59817. export class SmoothStepBlock extends NodeMaterialBlock {
  59818. /**
  59819. * Creates a new SmoothStepBlock
  59820. * @param name defines the block name
  59821. */
  59822. constructor(name: string);
  59823. /**
  59824. * Gets the current class name
  59825. * @returns the class name
  59826. */
  59827. getClassName(): string;
  59828. /**
  59829. * Gets the value operand input component
  59830. */
  59831. get value(): NodeMaterialConnectionPoint;
  59832. /**
  59833. * Gets the first edge operand input component
  59834. */
  59835. get edge0(): NodeMaterialConnectionPoint;
  59836. /**
  59837. * Gets the second edge operand input component
  59838. */
  59839. get edge1(): NodeMaterialConnectionPoint;
  59840. /**
  59841. * Gets the output component
  59842. */
  59843. get output(): NodeMaterialConnectionPoint;
  59844. protected _buildBlock(state: NodeMaterialBuildState): this;
  59845. }
  59846. }
  59847. declare module BABYLON {
  59848. /**
  59849. * Block used to get the reciprocal (1 / x) of a value
  59850. */
  59851. export class ReciprocalBlock extends NodeMaterialBlock {
  59852. /**
  59853. * Creates a new ReciprocalBlock
  59854. * @param name defines the block name
  59855. */
  59856. constructor(name: string);
  59857. /**
  59858. * Gets the current class name
  59859. * @returns the class name
  59860. */
  59861. getClassName(): string;
  59862. /**
  59863. * Gets the input component
  59864. */
  59865. get input(): NodeMaterialConnectionPoint;
  59866. /**
  59867. * Gets the output component
  59868. */
  59869. get output(): NodeMaterialConnectionPoint;
  59870. protected _buildBlock(state: NodeMaterialBuildState): this;
  59871. }
  59872. }
  59873. declare module BABYLON {
  59874. /**
  59875. * Block used to replace a color by another one
  59876. */
  59877. export class ReplaceColorBlock extends NodeMaterialBlock {
  59878. /**
  59879. * Creates a new ReplaceColorBlock
  59880. * @param name defines the block name
  59881. */
  59882. constructor(name: string);
  59883. /**
  59884. * Gets the current class name
  59885. * @returns the class name
  59886. */
  59887. getClassName(): string;
  59888. /**
  59889. * Gets the value input component
  59890. */
  59891. get value(): NodeMaterialConnectionPoint;
  59892. /**
  59893. * Gets the reference input component
  59894. */
  59895. get reference(): NodeMaterialConnectionPoint;
  59896. /**
  59897. * Gets the distance input component
  59898. */
  59899. get distance(): NodeMaterialConnectionPoint;
  59900. /**
  59901. * Gets the replacement input component
  59902. */
  59903. get replacement(): NodeMaterialConnectionPoint;
  59904. /**
  59905. * Gets the output component
  59906. */
  59907. get output(): NodeMaterialConnectionPoint;
  59908. protected _buildBlock(state: NodeMaterialBuildState): this;
  59909. }
  59910. }
  59911. declare module BABYLON {
  59912. /**
  59913. * Block used to posterize a value
  59914. * @see https://en.wikipedia.org/wiki/Posterization
  59915. */
  59916. export class PosterizeBlock extends NodeMaterialBlock {
  59917. /**
  59918. * Creates a new PosterizeBlock
  59919. * @param name defines the block name
  59920. */
  59921. constructor(name: string);
  59922. /**
  59923. * Gets the current class name
  59924. * @returns the class name
  59925. */
  59926. getClassName(): string;
  59927. /**
  59928. * Gets the value input component
  59929. */
  59930. get value(): NodeMaterialConnectionPoint;
  59931. /**
  59932. * Gets the steps input component
  59933. */
  59934. get steps(): NodeMaterialConnectionPoint;
  59935. /**
  59936. * Gets the output component
  59937. */
  59938. get output(): NodeMaterialConnectionPoint;
  59939. protected _buildBlock(state: NodeMaterialBuildState): this;
  59940. }
  59941. }
  59942. declare module BABYLON {
  59943. /**
  59944. * Operations supported by the Wave block
  59945. */
  59946. export enum WaveBlockKind {
  59947. /** SawTooth */
  59948. SawTooth = 0,
  59949. /** Square */
  59950. Square = 1,
  59951. /** Triangle */
  59952. Triangle = 2
  59953. }
  59954. /**
  59955. * Block used to apply wave operation to floats
  59956. */
  59957. export class WaveBlock extends NodeMaterialBlock {
  59958. /**
  59959. * Gets or sets the kibnd of wave to be applied by the block
  59960. */
  59961. kind: WaveBlockKind;
  59962. /**
  59963. * Creates a new WaveBlock
  59964. * @param name defines the block name
  59965. */
  59966. constructor(name: string);
  59967. /**
  59968. * Gets the current class name
  59969. * @returns the class name
  59970. */
  59971. getClassName(): string;
  59972. /**
  59973. * Gets the input component
  59974. */
  59975. get input(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the output component
  59978. */
  59979. get output(): NodeMaterialConnectionPoint;
  59980. protected _buildBlock(state: NodeMaterialBuildState): this;
  59981. serialize(): any;
  59982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59983. }
  59984. }
  59985. declare module BABYLON {
  59986. /**
  59987. * Class used to store a color step for the GradientBlock
  59988. */
  59989. export class GradientBlockColorStep {
  59990. /**
  59991. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59992. */
  59993. step: number;
  59994. /**
  59995. * Gets or sets the color associated with this step
  59996. */
  59997. color: Color3;
  59998. /**
  59999. * Creates a new GradientBlockColorStep
  60000. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60001. * @param color defines the color associated with this step
  60002. */
  60003. constructor(
  60004. /**
  60005. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60006. */
  60007. step: number,
  60008. /**
  60009. * Gets or sets the color associated with this step
  60010. */
  60011. color: Color3);
  60012. }
  60013. /**
  60014. * Block used to return a color from a gradient based on an input value between 0 and 1
  60015. */
  60016. export class GradientBlock extends NodeMaterialBlock {
  60017. /**
  60018. * Gets or sets the list of color steps
  60019. */
  60020. colorSteps: GradientBlockColorStep[];
  60021. /**
  60022. * Creates a new GradientBlock
  60023. * @param name defines the block name
  60024. */
  60025. constructor(name: string);
  60026. /**
  60027. * Gets the current class name
  60028. * @returns the class name
  60029. */
  60030. getClassName(): string;
  60031. /**
  60032. * Gets the gradient input component
  60033. */
  60034. get gradient(): NodeMaterialConnectionPoint;
  60035. /**
  60036. * Gets the output component
  60037. */
  60038. get output(): NodeMaterialConnectionPoint;
  60039. private _writeColorConstant;
  60040. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60041. serialize(): any;
  60042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60043. protected _dumpPropertiesCode(): string;
  60044. }
  60045. }
  60046. declare module BABYLON {
  60047. /**
  60048. * Block used to normalize lerp between 2 values
  60049. */
  60050. export class NLerpBlock extends NodeMaterialBlock {
  60051. /**
  60052. * Creates a new NLerpBlock
  60053. * @param name defines the block name
  60054. */
  60055. constructor(name: string);
  60056. /**
  60057. * Gets the current class name
  60058. * @returns the class name
  60059. */
  60060. getClassName(): string;
  60061. /**
  60062. * Gets the left operand input component
  60063. */
  60064. get left(): NodeMaterialConnectionPoint;
  60065. /**
  60066. * Gets the right operand input component
  60067. */
  60068. get right(): NodeMaterialConnectionPoint;
  60069. /**
  60070. * Gets the gradient operand input component
  60071. */
  60072. get gradient(): NodeMaterialConnectionPoint;
  60073. /**
  60074. * Gets the output component
  60075. */
  60076. get output(): NodeMaterialConnectionPoint;
  60077. protected _buildBlock(state: NodeMaterialBuildState): this;
  60078. }
  60079. }
  60080. declare module BABYLON {
  60081. /**
  60082. * block used to Generate a Worley Noise 3D Noise Pattern
  60083. */
  60084. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60085. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60086. manhattanDistance: boolean;
  60087. /**
  60088. * Creates a new WorleyNoise3DBlock
  60089. * @param name defines the block name
  60090. */
  60091. constructor(name: string);
  60092. /**
  60093. * Gets the current class name
  60094. * @returns the class name
  60095. */
  60096. getClassName(): string;
  60097. /**
  60098. * Gets the seed input component
  60099. */
  60100. get seed(): NodeMaterialConnectionPoint;
  60101. /**
  60102. * Gets the jitter input component
  60103. */
  60104. get jitter(): NodeMaterialConnectionPoint;
  60105. /**
  60106. * Gets the output component
  60107. */
  60108. get output(): NodeMaterialConnectionPoint;
  60109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60110. /**
  60111. * Exposes the properties to the UI?
  60112. */
  60113. protected _dumpPropertiesCode(): string;
  60114. /**
  60115. * Exposes the properties to the Seralize?
  60116. */
  60117. serialize(): any;
  60118. /**
  60119. * Exposes the properties to the deseralize?
  60120. */
  60121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60122. }
  60123. }
  60124. declare module BABYLON {
  60125. /**
  60126. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60127. */
  60128. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60129. /**
  60130. * Creates a new SimplexPerlin3DBlock
  60131. * @param name defines the block name
  60132. */
  60133. constructor(name: string);
  60134. /**
  60135. * Gets the current class name
  60136. * @returns the class name
  60137. */
  60138. getClassName(): string;
  60139. /**
  60140. * Gets the seed operand input component
  60141. */
  60142. get seed(): NodeMaterialConnectionPoint;
  60143. /**
  60144. * Gets the output component
  60145. */
  60146. get output(): NodeMaterialConnectionPoint;
  60147. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60148. }
  60149. }
  60150. declare module BABYLON {
  60151. /**
  60152. * Block used to blend normals
  60153. */
  60154. export class NormalBlendBlock extends NodeMaterialBlock {
  60155. /**
  60156. * Creates a new NormalBlendBlock
  60157. * @param name defines the block name
  60158. */
  60159. constructor(name: string);
  60160. /**
  60161. * Gets the current class name
  60162. * @returns the class name
  60163. */
  60164. getClassName(): string;
  60165. /**
  60166. * Gets the first input component
  60167. */
  60168. get normalMap0(): NodeMaterialConnectionPoint;
  60169. /**
  60170. * Gets the second input component
  60171. */
  60172. get normalMap1(): NodeMaterialConnectionPoint;
  60173. /**
  60174. * Gets the output component
  60175. */
  60176. get output(): NodeMaterialConnectionPoint;
  60177. protected _buildBlock(state: NodeMaterialBuildState): this;
  60178. }
  60179. }
  60180. declare module BABYLON {
  60181. /**
  60182. * Block used to rotate a 2d vector by a given angle
  60183. */
  60184. export class Rotate2dBlock extends NodeMaterialBlock {
  60185. /**
  60186. * Creates a new Rotate2dBlock
  60187. * @param name defines the block name
  60188. */
  60189. constructor(name: string);
  60190. /**
  60191. * Gets the current class name
  60192. * @returns the class name
  60193. */
  60194. getClassName(): string;
  60195. /**
  60196. * Gets the input vector
  60197. */
  60198. get input(): NodeMaterialConnectionPoint;
  60199. /**
  60200. * Gets the input angle
  60201. */
  60202. get angle(): NodeMaterialConnectionPoint;
  60203. /**
  60204. * Gets the output component
  60205. */
  60206. get output(): NodeMaterialConnectionPoint;
  60207. autoConfigure(material: NodeMaterial): void;
  60208. protected _buildBlock(state: NodeMaterialBuildState): this;
  60209. }
  60210. }
  60211. declare module BABYLON {
  60212. /**
  60213. * Block used to get the reflected vector from a direction and a normal
  60214. */
  60215. export class ReflectBlock extends NodeMaterialBlock {
  60216. /**
  60217. * Creates a new ReflectBlock
  60218. * @param name defines the block name
  60219. */
  60220. constructor(name: string);
  60221. /**
  60222. * Gets the current class name
  60223. * @returns the class name
  60224. */
  60225. getClassName(): string;
  60226. /**
  60227. * Gets the incident component
  60228. */
  60229. get incident(): NodeMaterialConnectionPoint;
  60230. /**
  60231. * Gets the normal component
  60232. */
  60233. get normal(): NodeMaterialConnectionPoint;
  60234. /**
  60235. * Gets the output component
  60236. */
  60237. get output(): NodeMaterialConnectionPoint;
  60238. protected _buildBlock(state: NodeMaterialBuildState): this;
  60239. }
  60240. }
  60241. declare module BABYLON {
  60242. /**
  60243. * Block used to get the refracted vector from a direction and a normal
  60244. */
  60245. export class RefractBlock extends NodeMaterialBlock {
  60246. /**
  60247. * Creates a new RefractBlock
  60248. * @param name defines the block name
  60249. */
  60250. constructor(name: string);
  60251. /**
  60252. * Gets the current class name
  60253. * @returns the class name
  60254. */
  60255. getClassName(): string;
  60256. /**
  60257. * Gets the incident component
  60258. */
  60259. get incident(): NodeMaterialConnectionPoint;
  60260. /**
  60261. * Gets the normal component
  60262. */
  60263. get normal(): NodeMaterialConnectionPoint;
  60264. /**
  60265. * Gets the index of refraction component
  60266. */
  60267. get ior(): NodeMaterialConnectionPoint;
  60268. /**
  60269. * Gets the output component
  60270. */
  60271. get output(): NodeMaterialConnectionPoint;
  60272. protected _buildBlock(state: NodeMaterialBuildState): this;
  60273. }
  60274. }
  60275. declare module BABYLON {
  60276. /**
  60277. * Block used to desaturate a color
  60278. */
  60279. export class DesaturateBlock extends NodeMaterialBlock {
  60280. /**
  60281. * Creates a new DesaturateBlock
  60282. * @param name defines the block name
  60283. */
  60284. constructor(name: string);
  60285. /**
  60286. * Gets the current class name
  60287. * @returns the class name
  60288. */
  60289. getClassName(): string;
  60290. /**
  60291. * Gets the color operand input component
  60292. */
  60293. get color(): NodeMaterialConnectionPoint;
  60294. /**
  60295. * Gets the level operand input component
  60296. */
  60297. get level(): NodeMaterialConnectionPoint;
  60298. /**
  60299. * Gets the output component
  60300. */
  60301. get output(): NodeMaterialConnectionPoint;
  60302. protected _buildBlock(state: NodeMaterialBuildState): this;
  60303. }
  60304. }
  60305. declare module BABYLON {
  60306. /**
  60307. * Effect Render Options
  60308. */
  60309. export interface IEffectRendererOptions {
  60310. /**
  60311. * Defines the vertices positions.
  60312. */
  60313. positions?: number[];
  60314. /**
  60315. * Defines the indices.
  60316. */
  60317. indices?: number[];
  60318. }
  60319. /**
  60320. * Helper class to render one or more effects
  60321. */
  60322. export class EffectRenderer {
  60323. private engine;
  60324. private static _DefaultOptions;
  60325. private _vertexBuffers;
  60326. private _indexBuffer;
  60327. private _ringBufferIndex;
  60328. private _ringScreenBuffer;
  60329. private _fullscreenViewport;
  60330. private _getNextFrameBuffer;
  60331. /**
  60332. * Creates an effect renderer
  60333. * @param engine the engine to use for rendering
  60334. * @param options defines the options of the effect renderer
  60335. */
  60336. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60337. /**
  60338. * Sets the current viewport in normalized coordinates 0-1
  60339. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60340. */
  60341. setViewport(viewport?: Viewport): void;
  60342. /**
  60343. * Binds the embedded attributes buffer to the effect.
  60344. * @param effect Defines the effect to bind the attributes for
  60345. */
  60346. bindBuffers(effect: Effect): void;
  60347. /**
  60348. * Sets the current effect wrapper to use during draw.
  60349. * The effect needs to be ready before calling this api.
  60350. * This also sets the default full screen position attribute.
  60351. * @param effectWrapper Defines the effect to draw with
  60352. */
  60353. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60354. /**
  60355. * Draws a full screen quad.
  60356. */
  60357. draw(): void;
  60358. /**
  60359. * renders one or more effects to a specified texture
  60360. * @param effectWrappers list of effects to renderer
  60361. * @param outputTexture texture to draw to, if null it will render to the screen
  60362. */
  60363. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60364. /**
  60365. * Disposes of the effect renderer
  60366. */
  60367. dispose(): void;
  60368. }
  60369. /**
  60370. * Options to create an EffectWrapper
  60371. */
  60372. interface EffectWrapperCreationOptions {
  60373. /**
  60374. * Engine to use to create the effect
  60375. */
  60376. engine: ThinEngine;
  60377. /**
  60378. * Fragment shader for the effect
  60379. */
  60380. fragmentShader: string;
  60381. /**
  60382. * Vertex shader for the effect
  60383. */
  60384. vertexShader?: string;
  60385. /**
  60386. * Attributes to use in the shader
  60387. */
  60388. attributeNames?: Array<string>;
  60389. /**
  60390. * Uniforms to use in the shader
  60391. */
  60392. uniformNames?: Array<string>;
  60393. /**
  60394. * Texture sampler names to use in the shader
  60395. */
  60396. samplerNames?: Array<string>;
  60397. /**
  60398. * The friendly name of the effect displayed in Spector.
  60399. */
  60400. name?: string;
  60401. }
  60402. /**
  60403. * Wraps an effect to be used for rendering
  60404. */
  60405. export class EffectWrapper {
  60406. /**
  60407. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60408. */
  60409. onApplyObservable: Observable<{}>;
  60410. /**
  60411. * The underlying effect
  60412. */
  60413. effect: Effect;
  60414. /**
  60415. * Creates an effect to be renderer
  60416. * @param creationOptions options to create the effect
  60417. */
  60418. constructor(creationOptions: EffectWrapperCreationOptions);
  60419. /**
  60420. * Disposes of the effect wrapper
  60421. */
  60422. dispose(): void;
  60423. }
  60424. }
  60425. declare module BABYLON {
  60426. /**
  60427. * Helper class to push actions to a pool of workers.
  60428. */
  60429. export class WorkerPool implements IDisposable {
  60430. private _workerInfos;
  60431. private _pendingActions;
  60432. /**
  60433. * Constructor
  60434. * @param workers Array of workers to use for actions
  60435. */
  60436. constructor(workers: Array<Worker>);
  60437. /**
  60438. * Terminates all workers and clears any pending actions.
  60439. */
  60440. dispose(): void;
  60441. /**
  60442. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60443. * pended until a worker has completed its action.
  60444. * @param action The action to perform. Call onComplete when the action is complete.
  60445. */
  60446. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60447. private _execute;
  60448. }
  60449. }
  60450. declare module BABYLON {
  60451. /**
  60452. * Configuration for Draco compression
  60453. */
  60454. export interface IDracoCompressionConfiguration {
  60455. /**
  60456. * Configuration for the decoder.
  60457. */
  60458. decoder: {
  60459. /**
  60460. * The url to the WebAssembly module.
  60461. */
  60462. wasmUrl?: string;
  60463. /**
  60464. * The url to the WebAssembly binary.
  60465. */
  60466. wasmBinaryUrl?: string;
  60467. /**
  60468. * The url to the fallback JavaScript module.
  60469. */
  60470. fallbackUrl?: string;
  60471. };
  60472. }
  60473. /**
  60474. * Draco compression (https://google.github.io/draco/)
  60475. *
  60476. * This class wraps the Draco module.
  60477. *
  60478. * **Encoder**
  60479. *
  60480. * The encoder is not currently implemented.
  60481. *
  60482. * **Decoder**
  60483. *
  60484. * 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.
  60485. *
  60486. * To update the configuration, use the following code:
  60487. * ```javascript
  60488. * DracoCompression.Configuration = {
  60489. * decoder: {
  60490. * wasmUrl: "<url to the WebAssembly library>",
  60491. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60492. * fallbackUrl: "<url to the fallback JavaScript library>",
  60493. * }
  60494. * };
  60495. * ```
  60496. *
  60497. * 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.
  60498. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60499. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60500. *
  60501. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60502. * ```javascript
  60503. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60504. * ```
  60505. *
  60506. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60507. */
  60508. export class DracoCompression implements IDisposable {
  60509. private _workerPoolPromise?;
  60510. private _decoderModulePromise?;
  60511. /**
  60512. * The configuration. Defaults to the following urls:
  60513. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60514. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60515. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60516. */
  60517. static Configuration: IDracoCompressionConfiguration;
  60518. /**
  60519. * Returns true if the decoder configuration is available.
  60520. */
  60521. static get DecoderAvailable(): boolean;
  60522. /**
  60523. * Default number of workers to create when creating the draco compression object.
  60524. */
  60525. static DefaultNumWorkers: number;
  60526. private static GetDefaultNumWorkers;
  60527. private static _Default;
  60528. /**
  60529. * Default instance for the draco compression object.
  60530. */
  60531. static get Default(): DracoCompression;
  60532. /**
  60533. * Constructor
  60534. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60535. */
  60536. constructor(numWorkers?: number);
  60537. /**
  60538. * Stop all async operations and release resources.
  60539. */
  60540. dispose(): void;
  60541. /**
  60542. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60543. * @returns a promise that resolves when ready
  60544. */
  60545. whenReadyAsync(): Promise<void>;
  60546. /**
  60547. * Decode Draco compressed mesh data to vertex data.
  60548. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60549. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60550. * @returns A promise that resolves with the decoded vertex data
  60551. */
  60552. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60553. [kind: string]: number;
  60554. }): Promise<VertexData>;
  60555. }
  60556. }
  60557. declare module BABYLON {
  60558. /**
  60559. * Class for building Constructive Solid Geometry
  60560. */
  60561. export class CSG {
  60562. private polygons;
  60563. /**
  60564. * The world matrix
  60565. */
  60566. matrix: Matrix;
  60567. /**
  60568. * Stores the position
  60569. */
  60570. position: Vector3;
  60571. /**
  60572. * Stores the rotation
  60573. */
  60574. rotation: Vector3;
  60575. /**
  60576. * Stores the rotation quaternion
  60577. */
  60578. rotationQuaternion: Nullable<Quaternion>;
  60579. /**
  60580. * Stores the scaling vector
  60581. */
  60582. scaling: Vector3;
  60583. /**
  60584. * Convert the Mesh to CSG
  60585. * @param mesh The Mesh to convert to CSG
  60586. * @returns A new CSG from the Mesh
  60587. */
  60588. static FromMesh(mesh: Mesh): CSG;
  60589. /**
  60590. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60591. * @param polygons Polygons used to construct a CSG solid
  60592. */
  60593. private static FromPolygons;
  60594. /**
  60595. * Clones, or makes a deep copy, of the CSG
  60596. * @returns A new CSG
  60597. */
  60598. clone(): CSG;
  60599. /**
  60600. * Unions this CSG with another CSG
  60601. * @param csg The CSG to union against this CSG
  60602. * @returns The unioned CSG
  60603. */
  60604. union(csg: CSG): CSG;
  60605. /**
  60606. * Unions this CSG with another CSG in place
  60607. * @param csg The CSG to union against this CSG
  60608. */
  60609. unionInPlace(csg: CSG): void;
  60610. /**
  60611. * Subtracts this CSG with another CSG
  60612. * @param csg The CSG to subtract against this CSG
  60613. * @returns A new CSG
  60614. */
  60615. subtract(csg: CSG): CSG;
  60616. /**
  60617. * Subtracts this CSG with another CSG in place
  60618. * @param csg The CSG to subtact against this CSG
  60619. */
  60620. subtractInPlace(csg: CSG): void;
  60621. /**
  60622. * Intersect this CSG with another CSG
  60623. * @param csg The CSG to intersect against this CSG
  60624. * @returns A new CSG
  60625. */
  60626. intersect(csg: CSG): CSG;
  60627. /**
  60628. * Intersects this CSG with another CSG in place
  60629. * @param csg The CSG to intersect against this CSG
  60630. */
  60631. intersectInPlace(csg: CSG): void;
  60632. /**
  60633. * Return a new CSG solid with solid and empty space switched. This solid is
  60634. * not modified.
  60635. * @returns A new CSG solid with solid and empty space switched
  60636. */
  60637. inverse(): CSG;
  60638. /**
  60639. * Inverses the CSG in place
  60640. */
  60641. inverseInPlace(): void;
  60642. /**
  60643. * This is used to keep meshes transformations so they can be restored
  60644. * when we build back a Babylon Mesh
  60645. * NB : All CSG operations are performed in world coordinates
  60646. * @param csg The CSG to copy the transform attributes from
  60647. * @returns This CSG
  60648. */
  60649. copyTransformAttributes(csg: CSG): CSG;
  60650. /**
  60651. * Build Raw mesh from CSG
  60652. * Coordinates here are in world space
  60653. * @param name The name of the mesh geometry
  60654. * @param scene The Scene
  60655. * @param keepSubMeshes Specifies if the submeshes should be kept
  60656. * @returns A new Mesh
  60657. */
  60658. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60659. /**
  60660. * Build Mesh from CSG taking material and transforms into account
  60661. * @param name The name of the Mesh
  60662. * @param material The material of the Mesh
  60663. * @param scene The Scene
  60664. * @param keepSubMeshes Specifies if submeshes should be kept
  60665. * @returns The new Mesh
  60666. */
  60667. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60668. }
  60669. }
  60670. declare module BABYLON {
  60671. /**
  60672. * Class used to create a trail following a mesh
  60673. */
  60674. export class TrailMesh extends Mesh {
  60675. private _generator;
  60676. private _autoStart;
  60677. private _running;
  60678. private _diameter;
  60679. private _length;
  60680. private _sectionPolygonPointsCount;
  60681. private _sectionVectors;
  60682. private _sectionNormalVectors;
  60683. private _beforeRenderObserver;
  60684. /**
  60685. * @constructor
  60686. * @param name The value used by scene.getMeshByName() to do a lookup.
  60687. * @param generator The mesh or transform node to generate a trail.
  60688. * @param scene The scene to add this mesh to.
  60689. * @param diameter Diameter of trailing mesh. Default is 1.
  60690. * @param length Length of trailing mesh. Default is 60.
  60691. * @param autoStart Automatically start trailing mesh. Default true.
  60692. */
  60693. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60694. /**
  60695. * "TrailMesh"
  60696. * @returns "TrailMesh"
  60697. */
  60698. getClassName(): string;
  60699. private _createMesh;
  60700. /**
  60701. * Start trailing mesh.
  60702. */
  60703. start(): void;
  60704. /**
  60705. * Stop trailing mesh.
  60706. */
  60707. stop(): void;
  60708. /**
  60709. * Update trailing mesh geometry.
  60710. */
  60711. update(): void;
  60712. /**
  60713. * Returns a new TrailMesh object.
  60714. * @param name is a string, the name given to the new mesh
  60715. * @param newGenerator use new generator object for cloned trail mesh
  60716. * @returns a new mesh
  60717. */
  60718. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60719. /**
  60720. * Serializes this trail mesh
  60721. * @param serializationObject object to write serialization to
  60722. */
  60723. serialize(serializationObject: any): void;
  60724. /**
  60725. * Parses a serialized trail mesh
  60726. * @param parsedMesh the serialized mesh
  60727. * @param scene the scene to create the trail mesh in
  60728. * @returns the created trail mesh
  60729. */
  60730. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60731. }
  60732. }
  60733. declare module BABYLON {
  60734. /**
  60735. * Class containing static functions to help procedurally build meshes
  60736. */
  60737. export class TiledBoxBuilder {
  60738. /**
  60739. * Creates a box mesh
  60740. * 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)
  60741. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60743. * * 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
  60744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60745. * @param name defines the name of the mesh
  60746. * @param options defines the options used to create the mesh
  60747. * @param scene defines the hosting scene
  60748. * @returns the box mesh
  60749. */
  60750. static CreateTiledBox(name: string, options: {
  60751. pattern?: number;
  60752. width?: number;
  60753. height?: number;
  60754. depth?: number;
  60755. tileSize?: number;
  60756. tileWidth?: number;
  60757. tileHeight?: number;
  60758. alignHorizontal?: number;
  60759. alignVertical?: number;
  60760. faceUV?: Vector4[];
  60761. faceColors?: Color4[];
  60762. sideOrientation?: number;
  60763. updatable?: boolean;
  60764. }, scene?: Nullable<Scene>): Mesh;
  60765. }
  60766. }
  60767. declare module BABYLON {
  60768. /**
  60769. * Class containing static functions to help procedurally build meshes
  60770. */
  60771. export class TorusKnotBuilder {
  60772. /**
  60773. * Creates a torus knot mesh
  60774. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60775. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60776. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60777. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60779. * * 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
  60780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60781. * @param name defines the name of the mesh
  60782. * @param options defines the options used to create the mesh
  60783. * @param scene defines the hosting scene
  60784. * @returns the torus knot mesh
  60785. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60786. */
  60787. static CreateTorusKnot(name: string, options: {
  60788. radius?: number;
  60789. tube?: number;
  60790. radialSegments?: number;
  60791. tubularSegments?: number;
  60792. p?: number;
  60793. q?: number;
  60794. updatable?: boolean;
  60795. sideOrientation?: number;
  60796. frontUVs?: Vector4;
  60797. backUVs?: Vector4;
  60798. }, scene: any): Mesh;
  60799. }
  60800. }
  60801. declare module BABYLON {
  60802. /**
  60803. * Polygon
  60804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60805. */
  60806. export class Polygon {
  60807. /**
  60808. * Creates a rectangle
  60809. * @param xmin bottom X coord
  60810. * @param ymin bottom Y coord
  60811. * @param xmax top X coord
  60812. * @param ymax top Y coord
  60813. * @returns points that make the resulting rectation
  60814. */
  60815. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60816. /**
  60817. * Creates a circle
  60818. * @param radius radius of circle
  60819. * @param cx scale in x
  60820. * @param cy scale in y
  60821. * @param numberOfSides number of sides that make up the circle
  60822. * @returns points that make the resulting circle
  60823. */
  60824. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60825. /**
  60826. * Creates a polygon from input string
  60827. * @param input Input polygon data
  60828. * @returns the parsed points
  60829. */
  60830. static Parse(input: string): Vector2[];
  60831. /**
  60832. * Starts building a polygon from x and y coordinates
  60833. * @param x x coordinate
  60834. * @param y y coordinate
  60835. * @returns the started path2
  60836. */
  60837. static StartingAt(x: number, y: number): Path2;
  60838. }
  60839. /**
  60840. * Builds a polygon
  60841. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60842. */
  60843. export class PolygonMeshBuilder {
  60844. private _points;
  60845. private _outlinepoints;
  60846. private _holes;
  60847. private _name;
  60848. private _scene;
  60849. private _epoints;
  60850. private _eholes;
  60851. private _addToepoint;
  60852. /**
  60853. * Babylon reference to the earcut plugin.
  60854. */
  60855. bjsEarcut: any;
  60856. /**
  60857. * Creates a PolygonMeshBuilder
  60858. * @param name name of the builder
  60859. * @param contours Path of the polygon
  60860. * @param scene scene to add to when creating the mesh
  60861. * @param earcutInjection can be used to inject your own earcut reference
  60862. */
  60863. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60864. /**
  60865. * Adds a whole within the polygon
  60866. * @param hole Array of points defining the hole
  60867. * @returns this
  60868. */
  60869. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60870. /**
  60871. * Creates the polygon
  60872. * @param updatable If the mesh should be updatable
  60873. * @param depth The depth of the mesh created
  60874. * @returns the created mesh
  60875. */
  60876. build(updatable?: boolean, depth?: number): Mesh;
  60877. /**
  60878. * Creates the polygon
  60879. * @param depth The depth of the mesh created
  60880. * @returns the created VertexData
  60881. */
  60882. buildVertexData(depth?: number): VertexData;
  60883. /**
  60884. * Adds a side to the polygon
  60885. * @param positions points that make the polygon
  60886. * @param normals normals of the polygon
  60887. * @param uvs uvs of the polygon
  60888. * @param indices indices of the polygon
  60889. * @param bounds bounds of the polygon
  60890. * @param points points of the polygon
  60891. * @param depth depth of the polygon
  60892. * @param flip flip of the polygon
  60893. */
  60894. private addSide;
  60895. }
  60896. }
  60897. declare module BABYLON {
  60898. /**
  60899. * Class containing static functions to help procedurally build meshes
  60900. */
  60901. export class PolygonBuilder {
  60902. /**
  60903. * Creates a polygon mesh
  60904. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60905. * * 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
  60906. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60908. * * 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)
  60909. * * Remember you can only change the shape positions, not their number when updating a polygon
  60910. * @param name defines the name of the mesh
  60911. * @param options defines the options used to create the mesh
  60912. * @param scene defines the hosting scene
  60913. * @param earcutInjection can be used to inject your own earcut reference
  60914. * @returns the polygon mesh
  60915. */
  60916. static CreatePolygon(name: string, options: {
  60917. shape: Vector3[];
  60918. holes?: Vector3[][];
  60919. depth?: number;
  60920. faceUV?: Vector4[];
  60921. faceColors?: Color4[];
  60922. updatable?: boolean;
  60923. sideOrientation?: number;
  60924. frontUVs?: Vector4;
  60925. backUVs?: Vector4;
  60926. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60927. /**
  60928. * Creates an extruded polygon mesh, with depth in the Y direction.
  60929. * * 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)
  60930. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60931. * @param name defines the name of the mesh
  60932. * @param options defines the options used to create the mesh
  60933. * @param scene defines the hosting scene
  60934. * @param earcutInjection can be used to inject your own earcut reference
  60935. * @returns the polygon mesh
  60936. */
  60937. static ExtrudePolygon(name: string, options: {
  60938. shape: Vector3[];
  60939. holes?: Vector3[][];
  60940. depth?: number;
  60941. faceUV?: Vector4[];
  60942. faceColors?: Color4[];
  60943. updatable?: boolean;
  60944. sideOrientation?: number;
  60945. frontUVs?: Vector4;
  60946. backUVs?: Vector4;
  60947. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60948. }
  60949. }
  60950. declare module BABYLON {
  60951. /**
  60952. * Class containing static functions to help procedurally build meshes
  60953. */
  60954. export class LatheBuilder {
  60955. /**
  60956. * Creates lathe mesh.
  60957. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60958. * * 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
  60959. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60960. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60961. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60962. * * 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
  60963. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60964. * * 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
  60965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60966. * * 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
  60967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60969. * @param name defines the name of the mesh
  60970. * @param options defines the options used to create the mesh
  60971. * @param scene defines the hosting scene
  60972. * @returns the lathe mesh
  60973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60974. */
  60975. static CreateLathe(name: string, options: {
  60976. shape: Vector3[];
  60977. radius?: number;
  60978. tessellation?: number;
  60979. clip?: number;
  60980. arc?: number;
  60981. closed?: boolean;
  60982. updatable?: boolean;
  60983. sideOrientation?: number;
  60984. frontUVs?: Vector4;
  60985. backUVs?: Vector4;
  60986. cap?: number;
  60987. invertUV?: boolean;
  60988. }, scene?: Nullable<Scene>): Mesh;
  60989. }
  60990. }
  60991. declare module BABYLON {
  60992. /**
  60993. * Class containing static functions to help procedurally build meshes
  60994. */
  60995. export class TiledPlaneBuilder {
  60996. /**
  60997. * Creates a tiled plane mesh
  60998. * * The parameter `pattern` will, depending on value, do nothing or
  60999. * * * flip (reflect about central vertical) alternate tiles across and up
  61000. * * * flip every tile on alternate rows
  61001. * * * rotate (180 degs) alternate tiles across and up
  61002. * * * rotate every tile on alternate rows
  61003. * * * flip and rotate alternate tiles across and up
  61004. * * * flip and rotate every tile on alternate rows
  61005. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61006. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61007. * * 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
  61008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61009. * * 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)
  61010. * * 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)
  61011. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61012. * @param name defines the name of the mesh
  61013. * @param options defines the options used to create the mesh
  61014. * @param scene defines the hosting scene
  61015. * @returns the box mesh
  61016. */
  61017. static CreateTiledPlane(name: string, options: {
  61018. pattern?: number;
  61019. tileSize?: number;
  61020. tileWidth?: number;
  61021. tileHeight?: number;
  61022. size?: number;
  61023. width?: number;
  61024. height?: number;
  61025. alignHorizontal?: number;
  61026. alignVertical?: number;
  61027. sideOrientation?: number;
  61028. frontUVs?: Vector4;
  61029. backUVs?: Vector4;
  61030. updatable?: boolean;
  61031. }, scene?: Nullable<Scene>): Mesh;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * Class containing static functions to help procedurally build meshes
  61037. */
  61038. export class TubeBuilder {
  61039. /**
  61040. * Creates a tube mesh.
  61041. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61042. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61043. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61044. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61045. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61046. * * 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)
  61047. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61048. * * 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
  61049. * * 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
  61050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61051. * * 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
  61052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61054. * @param name defines the name of the mesh
  61055. * @param options defines the options used to create the mesh
  61056. * @param scene defines the hosting scene
  61057. * @returns the tube mesh
  61058. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61059. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61060. */
  61061. static CreateTube(name: string, options: {
  61062. path: Vector3[];
  61063. radius?: number;
  61064. tessellation?: number;
  61065. radiusFunction?: {
  61066. (i: number, distance: number): number;
  61067. };
  61068. cap?: number;
  61069. arc?: number;
  61070. updatable?: boolean;
  61071. sideOrientation?: number;
  61072. frontUVs?: Vector4;
  61073. backUVs?: Vector4;
  61074. instance?: Mesh;
  61075. invertUV?: boolean;
  61076. }, scene?: Nullable<Scene>): Mesh;
  61077. }
  61078. }
  61079. declare module BABYLON {
  61080. /**
  61081. * Class containing static functions to help procedurally build meshes
  61082. */
  61083. export class IcoSphereBuilder {
  61084. /**
  61085. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61086. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61087. * * 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`)
  61088. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61089. * * 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
  61090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61091. * * 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
  61092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61093. * @param name defines the name of the mesh
  61094. * @param options defines the options used to create the mesh
  61095. * @param scene defines the hosting scene
  61096. * @returns the icosahedron mesh
  61097. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61098. */
  61099. static CreateIcoSphere(name: string, options: {
  61100. radius?: number;
  61101. radiusX?: number;
  61102. radiusY?: number;
  61103. radiusZ?: number;
  61104. flat?: boolean;
  61105. subdivisions?: number;
  61106. sideOrientation?: number;
  61107. frontUVs?: Vector4;
  61108. backUVs?: Vector4;
  61109. updatable?: boolean;
  61110. }, scene?: Nullable<Scene>): Mesh;
  61111. }
  61112. }
  61113. declare module BABYLON {
  61114. /**
  61115. * Class containing static functions to help procedurally build meshes
  61116. */
  61117. export class DecalBuilder {
  61118. /**
  61119. * Creates a decal mesh.
  61120. * 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
  61121. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61122. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61123. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61124. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61125. * @param name defines the name of the mesh
  61126. * @param sourceMesh defines the mesh where the decal must be applied
  61127. * @param options defines the options used to create the mesh
  61128. * @param scene defines the hosting scene
  61129. * @returns the decal mesh
  61130. * @see https://doc.babylonjs.com/how_to/decals
  61131. */
  61132. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61133. position?: Vector3;
  61134. normal?: Vector3;
  61135. size?: Vector3;
  61136. angle?: number;
  61137. }): Mesh;
  61138. }
  61139. }
  61140. declare module BABYLON {
  61141. /**
  61142. * Class containing static functions to help procedurally build meshes
  61143. */
  61144. export class MeshBuilder {
  61145. /**
  61146. * Creates a box mesh
  61147. * * The parameter `size` sets the size (float) of each box side (default 1)
  61148. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61149. * * 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)
  61150. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61152. * * 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
  61153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61154. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61155. * @param name defines the name of the mesh
  61156. * @param options defines the options used to create the mesh
  61157. * @param scene defines the hosting scene
  61158. * @returns the box mesh
  61159. */
  61160. static CreateBox(name: string, options: {
  61161. size?: number;
  61162. width?: number;
  61163. height?: number;
  61164. depth?: number;
  61165. faceUV?: Vector4[];
  61166. faceColors?: Color4[];
  61167. sideOrientation?: number;
  61168. frontUVs?: Vector4;
  61169. backUVs?: Vector4;
  61170. wrap?: boolean;
  61171. topBaseAt?: number;
  61172. bottomBaseAt?: number;
  61173. updatable?: boolean;
  61174. }, scene?: Nullable<Scene>): Mesh;
  61175. /**
  61176. * Creates a tiled box mesh
  61177. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61179. * @param name defines the name of the mesh
  61180. * @param options defines the options used to create the mesh
  61181. * @param scene defines the hosting scene
  61182. * @returns the tiled box mesh
  61183. */
  61184. static CreateTiledBox(name: string, options: {
  61185. pattern?: number;
  61186. size?: number;
  61187. width?: number;
  61188. height?: number;
  61189. depth: number;
  61190. tileSize?: number;
  61191. tileWidth?: number;
  61192. tileHeight?: number;
  61193. faceUV?: Vector4[];
  61194. faceColors?: Color4[];
  61195. alignHorizontal?: number;
  61196. alignVertical?: number;
  61197. sideOrientation?: number;
  61198. updatable?: boolean;
  61199. }, scene?: Nullable<Scene>): Mesh;
  61200. /**
  61201. * Creates a sphere mesh
  61202. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61203. * * 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`)
  61204. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61205. * * 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
  61206. * * 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)
  61207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61208. * * 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
  61209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61210. * @param name defines the name of the mesh
  61211. * @param options defines the options used to create the mesh
  61212. * @param scene defines the hosting scene
  61213. * @returns the sphere mesh
  61214. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61215. */
  61216. static CreateSphere(name: string, options: {
  61217. segments?: number;
  61218. diameter?: number;
  61219. diameterX?: number;
  61220. diameterY?: number;
  61221. diameterZ?: number;
  61222. arc?: number;
  61223. slice?: number;
  61224. sideOrientation?: number;
  61225. frontUVs?: Vector4;
  61226. backUVs?: Vector4;
  61227. updatable?: boolean;
  61228. }, scene?: Nullable<Scene>): Mesh;
  61229. /**
  61230. * Creates a plane polygonal mesh. By default, this is a disc
  61231. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61232. * * 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
  61233. * * 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
  61234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61235. * * 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
  61236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61237. * @param name defines the name of the mesh
  61238. * @param options defines the options used to create the mesh
  61239. * @param scene defines the hosting scene
  61240. * @returns the plane polygonal mesh
  61241. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61242. */
  61243. static CreateDisc(name: string, options: {
  61244. radius?: number;
  61245. tessellation?: number;
  61246. arc?: number;
  61247. updatable?: boolean;
  61248. sideOrientation?: number;
  61249. frontUVs?: Vector4;
  61250. backUVs?: Vector4;
  61251. }, scene?: Nullable<Scene>): Mesh;
  61252. /**
  61253. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61254. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61255. * * 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`)
  61256. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61257. * * 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
  61258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61259. * * 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
  61260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61261. * @param name defines the name of the mesh
  61262. * @param options defines the options used to create the mesh
  61263. * @param scene defines the hosting scene
  61264. * @returns the icosahedron mesh
  61265. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61266. */
  61267. static CreateIcoSphere(name: string, options: {
  61268. radius?: number;
  61269. radiusX?: number;
  61270. radiusY?: number;
  61271. radiusZ?: number;
  61272. flat?: boolean;
  61273. subdivisions?: number;
  61274. sideOrientation?: number;
  61275. frontUVs?: Vector4;
  61276. backUVs?: Vector4;
  61277. updatable?: boolean;
  61278. }, scene?: Nullable<Scene>): Mesh;
  61279. /**
  61280. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61281. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61282. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61283. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61284. * * 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
  61285. * * 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
  61286. * * 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
  61287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61288. * * 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
  61289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61290. * * 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
  61291. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61292. * * 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
  61293. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61295. * @param name defines the name of the mesh
  61296. * @param options defines the options used to create the mesh
  61297. * @param scene defines the hosting scene
  61298. * @returns the ribbon mesh
  61299. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61301. */
  61302. static CreateRibbon(name: string, options: {
  61303. pathArray: Vector3[][];
  61304. closeArray?: boolean;
  61305. closePath?: boolean;
  61306. offset?: number;
  61307. updatable?: boolean;
  61308. sideOrientation?: number;
  61309. frontUVs?: Vector4;
  61310. backUVs?: Vector4;
  61311. instance?: Mesh;
  61312. invertUV?: boolean;
  61313. uvs?: Vector2[];
  61314. colors?: Color4[];
  61315. }, scene?: Nullable<Scene>): Mesh;
  61316. /**
  61317. * Creates a cylinder or a cone mesh
  61318. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61319. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61320. * * 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.
  61321. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61322. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61323. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61324. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61325. * * 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).
  61326. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61327. * * 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).
  61328. * * 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
  61329. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61330. * * 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
  61331. * * 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.
  61332. * * If `enclose` is false, a ring surface is one element.
  61333. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61334. * * 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
  61335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61336. * * 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
  61337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61338. * @param name defines the name of the mesh
  61339. * @param options defines the options used to create the mesh
  61340. * @param scene defines the hosting scene
  61341. * @returns the cylinder mesh
  61342. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61343. */
  61344. static CreateCylinder(name: string, options: {
  61345. height?: number;
  61346. diameterTop?: number;
  61347. diameterBottom?: number;
  61348. diameter?: number;
  61349. tessellation?: number;
  61350. subdivisions?: number;
  61351. arc?: number;
  61352. faceColors?: Color4[];
  61353. faceUV?: Vector4[];
  61354. updatable?: boolean;
  61355. hasRings?: boolean;
  61356. enclose?: boolean;
  61357. cap?: number;
  61358. sideOrientation?: number;
  61359. frontUVs?: Vector4;
  61360. backUVs?: Vector4;
  61361. }, scene?: Nullable<Scene>): Mesh;
  61362. /**
  61363. * Creates a torus mesh
  61364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61368. * * 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
  61369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61370. * @param name defines the name of the mesh
  61371. * @param options defines the options used to create the mesh
  61372. * @param scene defines the hosting scene
  61373. * @returns the torus mesh
  61374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61375. */
  61376. static CreateTorus(name: string, options: {
  61377. diameter?: number;
  61378. thickness?: number;
  61379. tessellation?: number;
  61380. updatable?: boolean;
  61381. sideOrientation?: number;
  61382. frontUVs?: Vector4;
  61383. backUVs?: Vector4;
  61384. }, scene?: Nullable<Scene>): Mesh;
  61385. /**
  61386. * Creates a torus knot mesh
  61387. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61388. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61389. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61390. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61392. * * 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
  61393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61394. * @param name defines the name of the mesh
  61395. * @param options defines the options used to create the mesh
  61396. * @param scene defines the hosting scene
  61397. * @returns the torus knot mesh
  61398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61399. */
  61400. static CreateTorusKnot(name: string, options: {
  61401. radius?: number;
  61402. tube?: number;
  61403. radialSegments?: number;
  61404. tubularSegments?: number;
  61405. p?: number;
  61406. q?: number;
  61407. updatable?: boolean;
  61408. sideOrientation?: number;
  61409. frontUVs?: Vector4;
  61410. backUVs?: Vector4;
  61411. }, scene?: Nullable<Scene>): Mesh;
  61412. /**
  61413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61414. * * 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
  61415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61420. * * 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
  61421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61424. * @param name defines the name of the new line system
  61425. * @param options defines the options used to create the line system
  61426. * @param scene defines the hosting scene
  61427. * @returns a new line system mesh
  61428. */
  61429. static CreateLineSystem(name: string, options: {
  61430. lines: Vector3[][];
  61431. updatable?: boolean;
  61432. instance?: Nullable<LinesMesh>;
  61433. colors?: Nullable<Color4[][]>;
  61434. useVertexAlpha?: boolean;
  61435. }, scene: Nullable<Scene>): LinesMesh;
  61436. /**
  61437. * Creates a line mesh
  61438. * 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
  61439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61440. * * The parameter `points` is an array successive Vector3
  61441. * * 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
  61442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61444. * * When updating an instance, remember that only point positions can change, not the number of points
  61445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61447. * @param name defines the name of the new line system
  61448. * @param options defines the options used to create the line system
  61449. * @param scene defines the hosting scene
  61450. * @returns a new line mesh
  61451. */
  61452. static CreateLines(name: string, options: {
  61453. points: Vector3[];
  61454. updatable?: boolean;
  61455. instance?: Nullable<LinesMesh>;
  61456. colors?: Color4[];
  61457. useVertexAlpha?: boolean;
  61458. }, scene?: Nullable<Scene>): LinesMesh;
  61459. /**
  61460. * Creates a dashed line mesh
  61461. * * 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
  61462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61463. * * The parameter `points` is an array successive Vector3
  61464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61467. * * 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
  61468. * * When updating an instance, remember that only point positions can change, not the number of points
  61469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61470. * @param name defines the name of the mesh
  61471. * @param options defines the options used to create the mesh
  61472. * @param scene defines the hosting scene
  61473. * @returns the dashed line mesh
  61474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61475. */
  61476. static CreateDashedLines(name: string, options: {
  61477. points: Vector3[];
  61478. dashSize?: number;
  61479. gapSize?: number;
  61480. dashNb?: number;
  61481. updatable?: boolean;
  61482. instance?: LinesMesh;
  61483. }, scene?: Nullable<Scene>): LinesMesh;
  61484. /**
  61485. * 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.
  61486. * * 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.
  61487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61488. * * 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.
  61489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61490. * * 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
  61491. * * 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
  61492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61494. * * 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
  61495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61497. * @param name defines the name of the mesh
  61498. * @param options defines the options used to create the mesh
  61499. * @param scene defines the hosting scene
  61500. * @returns the extruded shape mesh
  61501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61503. */
  61504. static ExtrudeShape(name: string, options: {
  61505. shape: Vector3[];
  61506. path: Vector3[];
  61507. scale?: number;
  61508. rotation?: number;
  61509. cap?: number;
  61510. updatable?: boolean;
  61511. sideOrientation?: number;
  61512. frontUVs?: Vector4;
  61513. backUVs?: Vector4;
  61514. instance?: Mesh;
  61515. invertUV?: boolean;
  61516. }, scene?: Nullable<Scene>): Mesh;
  61517. /**
  61518. * Creates an custom extruded shape mesh.
  61519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61520. * * 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.
  61521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61522. * * 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
  61523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61524. * * 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
  61525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61528. * * 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
  61529. * * 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
  61530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61532. * * 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
  61533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61535. * @param name defines the name of the mesh
  61536. * @param options defines the options used to create the mesh
  61537. * @param scene defines the hosting scene
  61538. * @returns the custom extruded shape mesh
  61539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61542. */
  61543. static ExtrudeShapeCustom(name: string, options: {
  61544. shape: Vector3[];
  61545. path: Vector3[];
  61546. scaleFunction?: any;
  61547. rotationFunction?: any;
  61548. ribbonCloseArray?: boolean;
  61549. ribbonClosePath?: boolean;
  61550. cap?: number;
  61551. updatable?: boolean;
  61552. sideOrientation?: number;
  61553. frontUVs?: Vector4;
  61554. backUVs?: Vector4;
  61555. instance?: Mesh;
  61556. invertUV?: boolean;
  61557. }, scene?: Nullable<Scene>): Mesh;
  61558. /**
  61559. * Creates lathe mesh.
  61560. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61561. * * 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
  61562. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61563. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61564. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61565. * * 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
  61566. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61567. * * 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
  61568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61569. * * 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
  61570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61572. * @param name defines the name of the mesh
  61573. * @param options defines the options used to create the mesh
  61574. * @param scene defines the hosting scene
  61575. * @returns the lathe mesh
  61576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61577. */
  61578. static CreateLathe(name: string, options: {
  61579. shape: Vector3[];
  61580. radius?: number;
  61581. tessellation?: number;
  61582. clip?: number;
  61583. arc?: number;
  61584. closed?: boolean;
  61585. updatable?: boolean;
  61586. sideOrientation?: number;
  61587. frontUVs?: Vector4;
  61588. backUVs?: Vector4;
  61589. cap?: number;
  61590. invertUV?: boolean;
  61591. }, scene?: Nullable<Scene>): Mesh;
  61592. /**
  61593. * Creates a tiled plane mesh
  61594. * * You can set a limited pattern arrangement with the tiles
  61595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61596. * * 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
  61597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 plane mesh
  61602. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61603. */
  61604. static CreateTiledPlane(name: string, options: {
  61605. pattern?: number;
  61606. tileSize?: number;
  61607. tileWidth?: number;
  61608. tileHeight?: number;
  61609. size?: number;
  61610. width?: number;
  61611. height?: number;
  61612. alignHorizontal?: number;
  61613. alignVertical?: number;
  61614. sideOrientation?: number;
  61615. frontUVs?: Vector4;
  61616. backUVs?: Vector4;
  61617. updatable?: boolean;
  61618. }, scene?: Nullable<Scene>): Mesh;
  61619. /**
  61620. * Creates a plane mesh
  61621. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61622. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61623. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61625. * * 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
  61626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61627. * @param name defines the name of the mesh
  61628. * @param options defines the options used to create the mesh
  61629. * @param scene defines the hosting scene
  61630. * @returns the plane mesh
  61631. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61632. */
  61633. static CreatePlane(name: string, options: {
  61634. size?: number;
  61635. width?: number;
  61636. height?: number;
  61637. sideOrientation?: number;
  61638. frontUVs?: Vector4;
  61639. backUVs?: Vector4;
  61640. updatable?: boolean;
  61641. sourcePlane?: Plane;
  61642. }, scene?: Nullable<Scene>): Mesh;
  61643. /**
  61644. * Creates a ground mesh
  61645. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61646. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61648. * @param name defines the name of the mesh
  61649. * @param options defines the options used to create the mesh
  61650. * @param scene defines the hosting scene
  61651. * @returns the ground mesh
  61652. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61653. */
  61654. static CreateGround(name: string, options: {
  61655. width?: number;
  61656. height?: number;
  61657. subdivisions?: number;
  61658. subdivisionsX?: number;
  61659. subdivisionsY?: number;
  61660. updatable?: boolean;
  61661. }, scene?: Nullable<Scene>): Mesh;
  61662. /**
  61663. * Creates a tiled ground mesh
  61664. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61665. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61666. * * 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
  61667. * * 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
  61668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61669. * @param name defines the name of the mesh
  61670. * @param options defines the options used to create the mesh
  61671. * @param scene defines the hosting scene
  61672. * @returns the tiled ground mesh
  61673. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61674. */
  61675. static CreateTiledGround(name: string, options: {
  61676. xmin: number;
  61677. zmin: number;
  61678. xmax: number;
  61679. zmax: number;
  61680. subdivisions?: {
  61681. w: number;
  61682. h: number;
  61683. };
  61684. precision?: {
  61685. w: number;
  61686. h: number;
  61687. };
  61688. updatable?: boolean;
  61689. }, scene?: Nullable<Scene>): Mesh;
  61690. /**
  61691. * Creates a ground mesh from a height map
  61692. * * The parameter `url` sets the URL of the height map image resource.
  61693. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61694. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61695. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61696. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61697. * * 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.
  61698. * * 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).
  61699. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61701. * @param name defines the name of the mesh
  61702. * @param url defines the url to the height map
  61703. * @param options defines the options used to create the mesh
  61704. * @param scene defines the hosting scene
  61705. * @returns the ground mesh
  61706. * @see https://doc.babylonjs.com/babylon101/height_map
  61707. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61708. */
  61709. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61710. width?: number;
  61711. height?: number;
  61712. subdivisions?: number;
  61713. minHeight?: number;
  61714. maxHeight?: number;
  61715. colorFilter?: Color3;
  61716. alphaFilter?: number;
  61717. updatable?: boolean;
  61718. onReady?: (mesh: GroundMesh) => void;
  61719. }, scene?: Nullable<Scene>): GroundMesh;
  61720. /**
  61721. * Creates a polygon mesh
  61722. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61723. * * 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
  61724. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61726. * * 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)
  61727. * * Remember you can only change the shape positions, not their number when updating a polygon
  61728. * @param name defines the name of the mesh
  61729. * @param options defines the options used to create the mesh
  61730. * @param scene defines the hosting scene
  61731. * @param earcutInjection can be used to inject your own earcut reference
  61732. * @returns the polygon mesh
  61733. */
  61734. static CreatePolygon(name: string, options: {
  61735. shape: Vector3[];
  61736. holes?: Vector3[][];
  61737. depth?: number;
  61738. faceUV?: Vector4[];
  61739. faceColors?: Color4[];
  61740. updatable?: boolean;
  61741. sideOrientation?: number;
  61742. frontUVs?: Vector4;
  61743. backUVs?: Vector4;
  61744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61745. /**
  61746. * Creates an extruded polygon mesh, with depth in the Y direction.
  61747. * * 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)
  61748. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61749. * @param name defines the name of the mesh
  61750. * @param options defines the options used to create the mesh
  61751. * @param scene defines the hosting scene
  61752. * @param earcutInjection can be used to inject your own earcut reference
  61753. * @returns the polygon mesh
  61754. */
  61755. static ExtrudePolygon(name: string, options: {
  61756. shape: Vector3[];
  61757. holes?: Vector3[][];
  61758. depth?: number;
  61759. faceUV?: Vector4[];
  61760. faceColors?: Color4[];
  61761. updatable?: boolean;
  61762. sideOrientation?: number;
  61763. frontUVs?: Vector4;
  61764. backUVs?: Vector4;
  61765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61766. /**
  61767. * Creates a tube mesh.
  61768. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61769. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61770. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61771. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61772. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61773. * * 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)
  61774. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61775. * * 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
  61776. * * 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
  61777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61778. * * 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
  61779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61781. * @param name defines the name of the mesh
  61782. * @param options defines the options used to create the mesh
  61783. * @param scene defines the hosting scene
  61784. * @returns the tube mesh
  61785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61786. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61787. */
  61788. static CreateTube(name: string, options: {
  61789. path: Vector3[];
  61790. radius?: number;
  61791. tessellation?: number;
  61792. radiusFunction?: {
  61793. (i: number, distance: number): number;
  61794. };
  61795. cap?: number;
  61796. arc?: number;
  61797. updatable?: boolean;
  61798. sideOrientation?: number;
  61799. frontUVs?: Vector4;
  61800. backUVs?: Vector4;
  61801. instance?: Mesh;
  61802. invertUV?: boolean;
  61803. }, scene?: Nullable<Scene>): Mesh;
  61804. /**
  61805. * Creates a polyhedron mesh
  61806. * * 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
  61807. * * The parameter `size` (positive float, default 1) sets the polygon size
  61808. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61809. * * 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`
  61810. * * 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
  61811. * * 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)`)
  61812. * * 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
  61813. * * 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
  61814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61815. * * 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
  61816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61817. * @param name defines the name of the mesh
  61818. * @param options defines the options used to create the mesh
  61819. * @param scene defines the hosting scene
  61820. * @returns the polyhedron mesh
  61821. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61822. */
  61823. static CreatePolyhedron(name: string, options: {
  61824. type?: number;
  61825. size?: number;
  61826. sizeX?: number;
  61827. sizeY?: number;
  61828. sizeZ?: number;
  61829. custom?: any;
  61830. faceUV?: Vector4[];
  61831. faceColors?: Color4[];
  61832. flat?: boolean;
  61833. updatable?: boolean;
  61834. sideOrientation?: number;
  61835. frontUVs?: Vector4;
  61836. backUVs?: Vector4;
  61837. }, scene?: Nullable<Scene>): Mesh;
  61838. /**
  61839. * Creates a decal mesh.
  61840. * 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
  61841. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61842. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61843. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61844. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61845. * @param name defines the name of the mesh
  61846. * @param sourceMesh defines the mesh where the decal must be applied
  61847. * @param options defines the options used to create the mesh
  61848. * @param scene defines the hosting scene
  61849. * @returns the decal mesh
  61850. * @see https://doc.babylonjs.com/how_to/decals
  61851. */
  61852. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61853. position?: Vector3;
  61854. normal?: Vector3;
  61855. size?: Vector3;
  61856. angle?: number;
  61857. }): Mesh;
  61858. }
  61859. }
  61860. declare module BABYLON {
  61861. /**
  61862. * A simplifier interface for future simplification implementations
  61863. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61864. */
  61865. export interface ISimplifier {
  61866. /**
  61867. * Simplification of a given mesh according to the given settings.
  61868. * Since this requires computation, it is assumed that the function runs async.
  61869. * @param settings The settings of the simplification, including quality and distance
  61870. * @param successCallback A callback that will be called after the mesh was simplified.
  61871. * @param errorCallback in case of an error, this callback will be called. optional.
  61872. */
  61873. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61874. }
  61875. /**
  61876. * Expected simplification settings.
  61877. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61879. */
  61880. export interface ISimplificationSettings {
  61881. /**
  61882. * Gets or sets the expected quality
  61883. */
  61884. quality: number;
  61885. /**
  61886. * Gets or sets the distance when this optimized version should be used
  61887. */
  61888. distance: number;
  61889. /**
  61890. * Gets an already optimized mesh
  61891. */
  61892. optimizeMesh?: boolean;
  61893. }
  61894. /**
  61895. * Class used to specify simplification options
  61896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61897. */
  61898. export class SimplificationSettings implements ISimplificationSettings {
  61899. /** expected quality */
  61900. quality: number;
  61901. /** distance when this optimized version should be used */
  61902. distance: number;
  61903. /** already optimized mesh */
  61904. optimizeMesh?: boolean | undefined;
  61905. /**
  61906. * Creates a SimplificationSettings
  61907. * @param quality expected quality
  61908. * @param distance distance when this optimized version should be used
  61909. * @param optimizeMesh already optimized mesh
  61910. */
  61911. constructor(
  61912. /** expected quality */
  61913. quality: number,
  61914. /** distance when this optimized version should be used */
  61915. distance: number,
  61916. /** already optimized mesh */
  61917. optimizeMesh?: boolean | undefined);
  61918. }
  61919. /**
  61920. * Interface used to define a simplification task
  61921. */
  61922. export interface ISimplificationTask {
  61923. /**
  61924. * Array of settings
  61925. */
  61926. settings: Array<ISimplificationSettings>;
  61927. /**
  61928. * Simplification type
  61929. */
  61930. simplificationType: SimplificationType;
  61931. /**
  61932. * Mesh to simplify
  61933. */
  61934. mesh: Mesh;
  61935. /**
  61936. * Callback called on success
  61937. */
  61938. successCallback?: () => void;
  61939. /**
  61940. * Defines if parallel processing can be used
  61941. */
  61942. parallelProcessing: boolean;
  61943. }
  61944. /**
  61945. * Queue used to order the simplification tasks
  61946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61947. */
  61948. export class SimplificationQueue {
  61949. private _simplificationArray;
  61950. /**
  61951. * Gets a boolean indicating that the process is still running
  61952. */
  61953. running: boolean;
  61954. /**
  61955. * Creates a new queue
  61956. */
  61957. constructor();
  61958. /**
  61959. * Adds a new simplification task
  61960. * @param task defines a task to add
  61961. */
  61962. addTask(task: ISimplificationTask): void;
  61963. /**
  61964. * Execute next task
  61965. */
  61966. executeNext(): void;
  61967. /**
  61968. * Execute a simplification task
  61969. * @param task defines the task to run
  61970. */
  61971. runSimplification(task: ISimplificationTask): void;
  61972. private getSimplifier;
  61973. }
  61974. /**
  61975. * The implemented types of simplification
  61976. * At the moment only Quadratic Error Decimation is implemented
  61977. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61978. */
  61979. export enum SimplificationType {
  61980. /** Quadratic error decimation */
  61981. QUADRATIC = 0
  61982. }
  61983. /**
  61984. * An implementation of the Quadratic Error simplification algorithm.
  61985. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  61986. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  61987. * @author RaananW
  61988. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61989. */
  61990. export class QuadraticErrorSimplification implements ISimplifier {
  61991. private _mesh;
  61992. private triangles;
  61993. private vertices;
  61994. private references;
  61995. private _reconstructedMesh;
  61996. /** Gets or sets the number pf sync interations */
  61997. syncIterations: number;
  61998. /** Gets or sets the aggressiveness of the simplifier */
  61999. aggressiveness: number;
  62000. /** Gets or sets the number of allowed iterations for decimation */
  62001. decimationIterations: number;
  62002. /** Gets or sets the espilon to use for bounding box computation */
  62003. boundingBoxEpsilon: number;
  62004. /**
  62005. * Creates a new QuadraticErrorSimplification
  62006. * @param _mesh defines the target mesh
  62007. */
  62008. constructor(_mesh: Mesh);
  62009. /**
  62010. * Simplification of a given mesh according to the given settings.
  62011. * Since this requires computation, it is assumed that the function runs async.
  62012. * @param settings The settings of the simplification, including quality and distance
  62013. * @param successCallback A callback that will be called after the mesh was simplified.
  62014. */
  62015. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62016. private runDecimation;
  62017. private initWithMesh;
  62018. private init;
  62019. private reconstructMesh;
  62020. private initDecimatedMesh;
  62021. private isFlipped;
  62022. private updateTriangles;
  62023. private identifyBorder;
  62024. private updateMesh;
  62025. private vertexError;
  62026. private calculateError;
  62027. }
  62028. }
  62029. declare module BABYLON {
  62030. interface Scene {
  62031. /** @hidden (Backing field) */
  62032. _simplificationQueue: SimplificationQueue;
  62033. /**
  62034. * Gets or sets the simplification queue attached to the scene
  62035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62036. */
  62037. simplificationQueue: SimplificationQueue;
  62038. }
  62039. interface Mesh {
  62040. /**
  62041. * Simplify the mesh according to the given array of settings.
  62042. * Function will return immediately and will simplify async
  62043. * @param settings a collection of simplification settings
  62044. * @param parallelProcessing should all levels calculate parallel or one after the other
  62045. * @param simplificationType the type of simplification to run
  62046. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62047. * @returns the current mesh
  62048. */
  62049. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62050. }
  62051. /**
  62052. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62053. * created in a scene
  62054. */
  62055. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62056. /**
  62057. * The component name helpfull to identify the component in the list of scene components.
  62058. */
  62059. readonly name: string;
  62060. /**
  62061. * The scene the component belongs to.
  62062. */
  62063. scene: Scene;
  62064. /**
  62065. * Creates a new instance of the component for the given scene
  62066. * @param scene Defines the scene to register the component in
  62067. */
  62068. constructor(scene: Scene);
  62069. /**
  62070. * Registers the component in a given scene
  62071. */
  62072. register(): void;
  62073. /**
  62074. * Rebuilds the elements related to this component in case of
  62075. * context lost for instance.
  62076. */
  62077. rebuild(): void;
  62078. /**
  62079. * Disposes the component and the associated ressources
  62080. */
  62081. dispose(): void;
  62082. private _beforeCameraUpdate;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62088. */
  62089. export interface INavigationEnginePlugin {
  62090. /**
  62091. * plugin name
  62092. */
  62093. name: string;
  62094. /**
  62095. * Creates a navigation mesh
  62096. * @param meshes array of all the geometry used to compute the navigatio mesh
  62097. * @param parameters bunch of parameters used to filter geometry
  62098. */
  62099. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62100. /**
  62101. * Create a navigation mesh debug mesh
  62102. * @param scene is where the mesh will be added
  62103. * @returns debug display mesh
  62104. */
  62105. createDebugNavMesh(scene: Scene): Mesh;
  62106. /**
  62107. * Get a navigation mesh constrained position, closest to the parameter position
  62108. * @param position world position
  62109. * @returns the closest point to position constrained by the navigation mesh
  62110. */
  62111. getClosestPoint(position: Vector3): Vector3;
  62112. /**
  62113. * Get a navigation mesh constrained position, closest to the parameter position
  62114. * @param position world position
  62115. * @param result output the closest point to position constrained by the navigation mesh
  62116. */
  62117. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62118. /**
  62119. * Get a navigation mesh constrained position, within a particular radius
  62120. * @param position world position
  62121. * @param maxRadius the maximum distance to the constrained world position
  62122. * @returns the closest point to position constrained by the navigation mesh
  62123. */
  62124. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62125. /**
  62126. * Get a navigation mesh constrained position, within a particular radius
  62127. * @param position world position
  62128. * @param maxRadius the maximum distance to the constrained world position
  62129. * @param result output the closest point to position constrained by the navigation mesh
  62130. */
  62131. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62132. /**
  62133. * Compute the final position from a segment made of destination-position
  62134. * @param position world position
  62135. * @param destination world position
  62136. * @returns the resulting point along the navmesh
  62137. */
  62138. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62139. /**
  62140. * Compute the final position from a segment made of destination-position
  62141. * @param position world position
  62142. * @param destination world position
  62143. * @param result output the resulting point along the navmesh
  62144. */
  62145. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62146. /**
  62147. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62148. * @param start world position
  62149. * @param end world position
  62150. * @returns array containing world position composing the path
  62151. */
  62152. computePath(start: Vector3, end: Vector3): Vector3[];
  62153. /**
  62154. * If this plugin is supported
  62155. * @returns true if plugin is supported
  62156. */
  62157. isSupported(): boolean;
  62158. /**
  62159. * Create a new Crowd so you can add agents
  62160. * @param maxAgents the maximum agent count in the crowd
  62161. * @param maxAgentRadius the maximum radius an agent can have
  62162. * @param scene to attach the crowd to
  62163. * @returns the crowd you can add agents to
  62164. */
  62165. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62166. /**
  62167. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62168. * The queries will try to find a solution within those bounds
  62169. * default is (1,1,1)
  62170. * @param extent x,y,z value that define the extent around the queries point of reference
  62171. */
  62172. setDefaultQueryExtent(extent: Vector3): void;
  62173. /**
  62174. * Get the Bounding box extent specified by setDefaultQueryExtent
  62175. * @returns the box extent values
  62176. */
  62177. getDefaultQueryExtent(): Vector3;
  62178. /**
  62179. * build the navmesh from a previously saved state using getNavmeshData
  62180. * @param data the Uint8Array returned by getNavmeshData
  62181. */
  62182. buildFromNavmeshData(data: Uint8Array): void;
  62183. /**
  62184. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62185. * @returns data the Uint8Array that can be saved and reused
  62186. */
  62187. getNavmeshData(): Uint8Array;
  62188. /**
  62189. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62190. * @param result output the box extent values
  62191. */
  62192. getDefaultQueryExtentToRef(result: Vector3): void;
  62193. /**
  62194. * Release all resources
  62195. */
  62196. dispose(): void;
  62197. }
  62198. /**
  62199. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62200. */
  62201. export interface ICrowd {
  62202. /**
  62203. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62204. * You can attach anything to that node. The node position is updated in the scene update tick.
  62205. * @param pos world position that will be constrained by the navigation mesh
  62206. * @param parameters agent parameters
  62207. * @param transform hooked to the agent that will be update by the scene
  62208. * @returns agent index
  62209. */
  62210. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62211. /**
  62212. * Returns the agent position in world space
  62213. * @param index agent index returned by addAgent
  62214. * @returns world space position
  62215. */
  62216. getAgentPosition(index: number): Vector3;
  62217. /**
  62218. * Gets the agent position result in world space
  62219. * @param index agent index returned by addAgent
  62220. * @param result output world space position
  62221. */
  62222. getAgentPositionToRef(index: number, result: Vector3): void;
  62223. /**
  62224. * Gets the agent velocity in world space
  62225. * @param index agent index returned by addAgent
  62226. * @returns world space velocity
  62227. */
  62228. getAgentVelocity(index: number): Vector3;
  62229. /**
  62230. * Gets the agent velocity result in world space
  62231. * @param index agent index returned by addAgent
  62232. * @param result output world space velocity
  62233. */
  62234. getAgentVelocityToRef(index: number, result: Vector3): void;
  62235. /**
  62236. * remove a particular agent previously created
  62237. * @param index agent index returned by addAgent
  62238. */
  62239. removeAgent(index: number): void;
  62240. /**
  62241. * get the list of all agents attached to this crowd
  62242. * @returns list of agent indices
  62243. */
  62244. getAgents(): number[];
  62245. /**
  62246. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62247. * @param deltaTime in seconds
  62248. */
  62249. update(deltaTime: number): void;
  62250. /**
  62251. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62252. * @param index agent index returned by addAgent
  62253. * @param destination targeted world position
  62254. */
  62255. agentGoto(index: number, destination: Vector3): void;
  62256. /**
  62257. * Teleport the agent to a new position
  62258. * @param index agent index returned by addAgent
  62259. * @param destination targeted world position
  62260. */
  62261. agentTeleport(index: number, destination: Vector3): void;
  62262. /**
  62263. * Update agent parameters
  62264. * @param index agent index returned by addAgent
  62265. * @param parameters agent parameters
  62266. */
  62267. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62268. /**
  62269. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62270. * The queries will try to find a solution within those bounds
  62271. * default is (1,1,1)
  62272. * @param extent x,y,z value that define the extent around the queries point of reference
  62273. */
  62274. setDefaultQueryExtent(extent: Vector3): void;
  62275. /**
  62276. * Get the Bounding box extent specified by setDefaultQueryExtent
  62277. * @returns the box extent values
  62278. */
  62279. getDefaultQueryExtent(): Vector3;
  62280. /**
  62281. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62282. * @param result output the box extent values
  62283. */
  62284. getDefaultQueryExtentToRef(result: Vector3): void;
  62285. /**
  62286. * Release all resources
  62287. */
  62288. dispose(): void;
  62289. }
  62290. /**
  62291. * Configures an agent
  62292. */
  62293. export interface IAgentParameters {
  62294. /**
  62295. * Agent radius. [Limit: >= 0]
  62296. */
  62297. radius: number;
  62298. /**
  62299. * Agent height. [Limit: > 0]
  62300. */
  62301. height: number;
  62302. /**
  62303. * Maximum allowed acceleration. [Limit: >= 0]
  62304. */
  62305. maxAcceleration: number;
  62306. /**
  62307. * Maximum allowed speed. [Limit: >= 0]
  62308. */
  62309. maxSpeed: number;
  62310. /**
  62311. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62312. */
  62313. collisionQueryRange: number;
  62314. /**
  62315. * The path visibility optimization range. [Limit: > 0]
  62316. */
  62317. pathOptimizationRange: number;
  62318. /**
  62319. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62320. */
  62321. separationWeight: number;
  62322. }
  62323. /**
  62324. * Configures the navigation mesh creation
  62325. */
  62326. export interface INavMeshParameters {
  62327. /**
  62328. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62329. */
  62330. cs: number;
  62331. /**
  62332. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62333. */
  62334. ch: number;
  62335. /**
  62336. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62337. */
  62338. walkableSlopeAngle: number;
  62339. /**
  62340. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62341. * be considered walkable. [Limit: >= 3] [Units: vx]
  62342. */
  62343. walkableHeight: number;
  62344. /**
  62345. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62346. */
  62347. walkableClimb: number;
  62348. /**
  62349. * The distance to erode/shrink the walkable area of the heightfield away from
  62350. * obstructions. [Limit: >=0] [Units: vx]
  62351. */
  62352. walkableRadius: number;
  62353. /**
  62354. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62355. */
  62356. maxEdgeLen: number;
  62357. /**
  62358. * The maximum distance a simplfied contour's border edges should deviate
  62359. * the original raw contour. [Limit: >=0] [Units: vx]
  62360. */
  62361. maxSimplificationError: number;
  62362. /**
  62363. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62364. */
  62365. minRegionArea: number;
  62366. /**
  62367. * Any regions with a span count smaller than this value will, if possible,
  62368. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62369. */
  62370. mergeRegionArea: number;
  62371. /**
  62372. * The maximum number of vertices allowed for polygons generated during the
  62373. * contour to polygon conversion process. [Limit: >= 3]
  62374. */
  62375. maxVertsPerPoly: number;
  62376. /**
  62377. * Sets the sampling distance to use when generating the detail mesh.
  62378. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62379. */
  62380. detailSampleDist: number;
  62381. /**
  62382. * The maximum distance the detail mesh surface should deviate from heightfield
  62383. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62384. */
  62385. detailSampleMaxError: number;
  62386. }
  62387. }
  62388. declare module BABYLON {
  62389. /**
  62390. * RecastJS navigation plugin
  62391. */
  62392. export class RecastJSPlugin implements INavigationEnginePlugin {
  62393. /**
  62394. * Reference to the Recast library
  62395. */
  62396. bjsRECAST: any;
  62397. /**
  62398. * plugin name
  62399. */
  62400. name: string;
  62401. /**
  62402. * the first navmesh created. We might extend this to support multiple navmeshes
  62403. */
  62404. navMesh: any;
  62405. /**
  62406. * Initializes the recastJS plugin
  62407. * @param recastInjection can be used to inject your own recast reference
  62408. */
  62409. constructor(recastInjection?: any);
  62410. /**
  62411. * Creates a navigation mesh
  62412. * @param meshes array of all the geometry used to compute the navigatio mesh
  62413. * @param parameters bunch of parameters used to filter geometry
  62414. */
  62415. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62416. /**
  62417. * Create a navigation mesh debug mesh
  62418. * @param scene is where the mesh will be added
  62419. * @returns debug display mesh
  62420. */
  62421. createDebugNavMesh(scene: Scene): Mesh;
  62422. /**
  62423. * Get a navigation mesh constrained position, closest to the parameter position
  62424. * @param position world position
  62425. * @returns the closest point to position constrained by the navigation mesh
  62426. */
  62427. getClosestPoint(position: Vector3): Vector3;
  62428. /**
  62429. * Get a navigation mesh constrained position, closest to the parameter position
  62430. * @param position world position
  62431. * @param result output the closest point to position constrained by the navigation mesh
  62432. */
  62433. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62434. /**
  62435. * Get a navigation mesh constrained position, within a particular radius
  62436. * @param position world position
  62437. * @param maxRadius the maximum distance to the constrained world position
  62438. * @returns the closest point to position constrained by the navigation mesh
  62439. */
  62440. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62441. /**
  62442. * Get a navigation mesh constrained position, within a particular radius
  62443. * @param position world position
  62444. * @param maxRadius the maximum distance to the constrained world position
  62445. * @param result output the closest point to position constrained by the navigation mesh
  62446. */
  62447. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62448. /**
  62449. * Compute the final position from a segment made of destination-position
  62450. * @param position world position
  62451. * @param destination world position
  62452. * @returns the resulting point along the navmesh
  62453. */
  62454. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62455. /**
  62456. * Compute the final position from a segment made of destination-position
  62457. * @param position world position
  62458. * @param destination world position
  62459. * @param result output the resulting point along the navmesh
  62460. */
  62461. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62462. /**
  62463. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62464. * @param start world position
  62465. * @param end world position
  62466. * @returns array containing world position composing the path
  62467. */
  62468. computePath(start: Vector3, end: Vector3): Vector3[];
  62469. /**
  62470. * Create a new Crowd so you can add agents
  62471. * @param maxAgents the maximum agent count in the crowd
  62472. * @param maxAgentRadius the maximum radius an agent can have
  62473. * @param scene to attach the crowd to
  62474. * @returns the crowd you can add agents to
  62475. */
  62476. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62477. /**
  62478. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62479. * The queries will try to find a solution within those bounds
  62480. * default is (1,1,1)
  62481. * @param extent x,y,z value that define the extent around the queries point of reference
  62482. */
  62483. setDefaultQueryExtent(extent: Vector3): void;
  62484. /**
  62485. * Get the Bounding box extent specified by setDefaultQueryExtent
  62486. * @returns the box extent values
  62487. */
  62488. getDefaultQueryExtent(): Vector3;
  62489. /**
  62490. * build the navmesh from a previously saved state using getNavmeshData
  62491. * @param data the Uint8Array returned by getNavmeshData
  62492. */
  62493. buildFromNavmeshData(data: Uint8Array): void;
  62494. /**
  62495. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62496. * @returns data the Uint8Array that can be saved and reused
  62497. */
  62498. getNavmeshData(): Uint8Array;
  62499. /**
  62500. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62501. * @param result output the box extent values
  62502. */
  62503. getDefaultQueryExtentToRef(result: Vector3): void;
  62504. /**
  62505. * Disposes
  62506. */
  62507. dispose(): void;
  62508. /**
  62509. * If this plugin is supported
  62510. * @returns true if plugin is supported
  62511. */
  62512. isSupported(): boolean;
  62513. }
  62514. /**
  62515. * Recast detour crowd implementation
  62516. */
  62517. export class RecastJSCrowd implements ICrowd {
  62518. /**
  62519. * Recast/detour plugin
  62520. */
  62521. bjsRECASTPlugin: RecastJSPlugin;
  62522. /**
  62523. * Link to the detour crowd
  62524. */
  62525. recastCrowd: any;
  62526. /**
  62527. * One transform per agent
  62528. */
  62529. transforms: TransformNode[];
  62530. /**
  62531. * All agents created
  62532. */
  62533. agents: number[];
  62534. /**
  62535. * Link to the scene is kept to unregister the crowd from the scene
  62536. */
  62537. private _scene;
  62538. /**
  62539. * Observer for crowd updates
  62540. */
  62541. private _onBeforeAnimationsObserver;
  62542. /**
  62543. * Constructor
  62544. * @param plugin recastJS plugin
  62545. * @param maxAgents the maximum agent count in the crowd
  62546. * @param maxAgentRadius the maximum radius an agent can have
  62547. * @param scene to attach the crowd to
  62548. * @returns the crowd you can add agents to
  62549. */
  62550. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62551. /**
  62552. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62553. * You can attach anything to that node. The node position is updated in the scene update tick.
  62554. * @param pos world position that will be constrained by the navigation mesh
  62555. * @param parameters agent parameters
  62556. * @param transform hooked to the agent that will be update by the scene
  62557. * @returns agent index
  62558. */
  62559. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62560. /**
  62561. * Returns the agent position in world space
  62562. * @param index agent index returned by addAgent
  62563. * @returns world space position
  62564. */
  62565. getAgentPosition(index: number): Vector3;
  62566. /**
  62567. * Returns the agent position result in world space
  62568. * @param index agent index returned by addAgent
  62569. * @param result output world space position
  62570. */
  62571. getAgentPositionToRef(index: number, result: Vector3): void;
  62572. /**
  62573. * Returns the agent velocity in world space
  62574. * @param index agent index returned by addAgent
  62575. * @returns world space velocity
  62576. */
  62577. getAgentVelocity(index: number): Vector3;
  62578. /**
  62579. * Returns the agent velocity result in world space
  62580. * @param index agent index returned by addAgent
  62581. * @param result output world space velocity
  62582. */
  62583. getAgentVelocityToRef(index: number, result: Vector3): void;
  62584. /**
  62585. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62586. * @param index agent index returned by addAgent
  62587. * @param destination targeted world position
  62588. */
  62589. agentGoto(index: number, destination: Vector3): void;
  62590. /**
  62591. * Teleport the agent to a new position
  62592. * @param index agent index returned by addAgent
  62593. * @param destination targeted world position
  62594. */
  62595. agentTeleport(index: number, destination: Vector3): void;
  62596. /**
  62597. * Update agent parameters
  62598. * @param index agent index returned by addAgent
  62599. * @param parameters agent parameters
  62600. */
  62601. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62602. /**
  62603. * remove a particular agent previously created
  62604. * @param index agent index returned by addAgent
  62605. */
  62606. removeAgent(index: number): void;
  62607. /**
  62608. * get the list of all agents attached to this crowd
  62609. * @returns list of agent indices
  62610. */
  62611. getAgents(): number[];
  62612. /**
  62613. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62614. * @param deltaTime in seconds
  62615. */
  62616. update(deltaTime: number): void;
  62617. /**
  62618. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62619. * The queries will try to find a solution within those bounds
  62620. * default is (1,1,1)
  62621. * @param extent x,y,z value that define the extent around the queries point of reference
  62622. */
  62623. setDefaultQueryExtent(extent: Vector3): void;
  62624. /**
  62625. * Get the Bounding box extent specified by setDefaultQueryExtent
  62626. * @returns the box extent values
  62627. */
  62628. getDefaultQueryExtent(): Vector3;
  62629. /**
  62630. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62631. * @param result output the box extent values
  62632. */
  62633. getDefaultQueryExtentToRef(result: Vector3): void;
  62634. /**
  62635. * Release all resources
  62636. */
  62637. dispose(): void;
  62638. }
  62639. }
  62640. declare module BABYLON {
  62641. /**
  62642. * Class used to enable access to IndexedDB
  62643. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62644. */
  62645. export class Database implements IOfflineProvider {
  62646. private _callbackManifestChecked;
  62647. private _currentSceneUrl;
  62648. private _db;
  62649. private _enableSceneOffline;
  62650. private _enableTexturesOffline;
  62651. private _manifestVersionFound;
  62652. private _mustUpdateRessources;
  62653. private _hasReachedQuota;
  62654. private _isSupported;
  62655. private _idbFactory;
  62656. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62657. private static IsUASupportingBlobStorage;
  62658. /**
  62659. * Gets a boolean indicating if Database storate is enabled (off by default)
  62660. */
  62661. static IDBStorageEnabled: boolean;
  62662. /**
  62663. * Gets a boolean indicating if scene must be saved in the database
  62664. */
  62665. get enableSceneOffline(): boolean;
  62666. /**
  62667. * Gets a boolean indicating if textures must be saved in the database
  62668. */
  62669. get enableTexturesOffline(): boolean;
  62670. /**
  62671. * Creates a new Database
  62672. * @param urlToScene defines the url to load the scene
  62673. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62674. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62675. */
  62676. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62677. private static _ParseURL;
  62678. private static _ReturnFullUrlLocation;
  62679. private _checkManifestFile;
  62680. /**
  62681. * Open the database and make it available
  62682. * @param successCallback defines the callback to call on success
  62683. * @param errorCallback defines the callback to call on error
  62684. */
  62685. open(successCallback: () => void, errorCallback: () => void): void;
  62686. /**
  62687. * Loads an image from the database
  62688. * @param url defines the url to load from
  62689. * @param image defines the target DOM image
  62690. */
  62691. loadImage(url: string, image: HTMLImageElement): void;
  62692. private _loadImageFromDBAsync;
  62693. private _saveImageIntoDBAsync;
  62694. private _checkVersionFromDB;
  62695. private _loadVersionFromDBAsync;
  62696. private _saveVersionIntoDBAsync;
  62697. /**
  62698. * Loads a file from database
  62699. * @param url defines the URL to load from
  62700. * @param sceneLoaded defines a callback to call on success
  62701. * @param progressCallBack defines a callback to call when progress changed
  62702. * @param errorCallback defines a callback to call on error
  62703. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62704. */
  62705. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62706. private _loadFileAsync;
  62707. private _saveFileAsync;
  62708. /**
  62709. * Validates if xhr data is correct
  62710. * @param xhr defines the request to validate
  62711. * @param dataType defines the expected data type
  62712. * @returns true if data is correct
  62713. */
  62714. private static _ValidateXHRData;
  62715. }
  62716. }
  62717. declare module BABYLON {
  62718. /** @hidden */
  62719. export var gpuUpdateParticlesPixelShader: {
  62720. name: string;
  62721. shader: string;
  62722. };
  62723. }
  62724. declare module BABYLON {
  62725. /** @hidden */
  62726. export var gpuUpdateParticlesVertexShader: {
  62727. name: string;
  62728. shader: string;
  62729. };
  62730. }
  62731. declare module BABYLON {
  62732. /** @hidden */
  62733. export var clipPlaneFragmentDeclaration2: {
  62734. name: string;
  62735. shader: string;
  62736. };
  62737. }
  62738. declare module BABYLON {
  62739. /** @hidden */
  62740. export var gpuRenderParticlesPixelShader: {
  62741. name: string;
  62742. shader: string;
  62743. };
  62744. }
  62745. declare module BABYLON {
  62746. /** @hidden */
  62747. export var clipPlaneVertexDeclaration2: {
  62748. name: string;
  62749. shader: string;
  62750. };
  62751. }
  62752. declare module BABYLON {
  62753. /** @hidden */
  62754. export var gpuRenderParticlesVertexShader: {
  62755. name: string;
  62756. shader: string;
  62757. };
  62758. }
  62759. declare module BABYLON {
  62760. /**
  62761. * This represents a GPU particle system in Babylon
  62762. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62763. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62764. */
  62765. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62766. /**
  62767. * The layer mask we are rendering the particles through.
  62768. */
  62769. layerMask: number;
  62770. private _capacity;
  62771. private _activeCount;
  62772. private _currentActiveCount;
  62773. private _accumulatedCount;
  62774. private _renderEffect;
  62775. private _updateEffect;
  62776. private _buffer0;
  62777. private _buffer1;
  62778. private _spriteBuffer;
  62779. private _updateVAO;
  62780. private _renderVAO;
  62781. private _targetIndex;
  62782. private _sourceBuffer;
  62783. private _targetBuffer;
  62784. private _engine;
  62785. private _currentRenderId;
  62786. private _started;
  62787. private _stopped;
  62788. private _timeDelta;
  62789. private _randomTexture;
  62790. private _randomTexture2;
  62791. private _attributesStrideSize;
  62792. private _updateEffectOptions;
  62793. private _randomTextureSize;
  62794. private _actualFrame;
  62795. private readonly _rawTextureWidth;
  62796. /**
  62797. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62798. */
  62799. static get IsSupported(): boolean;
  62800. /**
  62801. * An event triggered when the system is disposed.
  62802. */
  62803. onDisposeObservable: Observable<GPUParticleSystem>;
  62804. /**
  62805. * Gets the maximum number of particles active at the same time.
  62806. * @returns The max number of active particles.
  62807. */
  62808. getCapacity(): number;
  62809. /**
  62810. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62811. * to override the particles.
  62812. */
  62813. forceDepthWrite: boolean;
  62814. /**
  62815. * Gets or set the number of active particles
  62816. */
  62817. get activeParticleCount(): number;
  62818. set activeParticleCount(value: number);
  62819. private _preWarmDone;
  62820. /**
  62821. * Specifies if the particles are updated in emitter local space or world space.
  62822. * This is always false for GPU particles
  62823. */
  62824. get isLocal(): boolean;
  62825. set isLocal(value: boolean);
  62826. /**
  62827. * Is this system ready to be used/rendered
  62828. * @return true if the system is ready
  62829. */
  62830. isReady(): boolean;
  62831. /**
  62832. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62833. * @returns True if it has been started, otherwise false.
  62834. */
  62835. isStarted(): boolean;
  62836. /**
  62837. * Starts the particle system and begins to emit
  62838. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62839. */
  62840. start(delay?: number): void;
  62841. /**
  62842. * Stops the particle system.
  62843. */
  62844. stop(): void;
  62845. /**
  62846. * Remove all active particles
  62847. */
  62848. reset(): void;
  62849. /**
  62850. * Returns the string "GPUParticleSystem"
  62851. * @returns a string containing the class name
  62852. */
  62853. getClassName(): string;
  62854. private _colorGradientsTexture;
  62855. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62856. /**
  62857. * Adds a new color gradient
  62858. * @param gradient defines the gradient to use (between 0 and 1)
  62859. * @param color1 defines the color to affect to the specified gradient
  62860. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62861. * @returns the current particle system
  62862. */
  62863. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62864. /**
  62865. * Remove a specific color gradient
  62866. * @param gradient defines the gradient to remove
  62867. * @returns the current particle system
  62868. */
  62869. removeColorGradient(gradient: number): GPUParticleSystem;
  62870. private _angularSpeedGradientsTexture;
  62871. private _sizeGradientsTexture;
  62872. private _velocityGradientsTexture;
  62873. private _limitVelocityGradientsTexture;
  62874. private _dragGradientsTexture;
  62875. private _addFactorGradient;
  62876. /**
  62877. * Adds a new size gradient
  62878. * @param gradient defines the gradient to use (between 0 and 1)
  62879. * @param factor defines the size factor to affect to the specified gradient
  62880. * @returns the current particle system
  62881. */
  62882. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62883. /**
  62884. * Remove a specific size gradient
  62885. * @param gradient defines the gradient to remove
  62886. * @returns the current particle system
  62887. */
  62888. removeSizeGradient(gradient: number): GPUParticleSystem;
  62889. /**
  62890. * Adds a new angular speed gradient
  62891. * @param gradient defines the gradient to use (between 0 and 1)
  62892. * @param factor defines the angular speed to affect to the specified gradient
  62893. * @returns the current particle system
  62894. */
  62895. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62896. /**
  62897. * Remove a specific angular speed gradient
  62898. * @param gradient defines the gradient to remove
  62899. * @returns the current particle system
  62900. */
  62901. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62902. /**
  62903. * Adds a new velocity gradient
  62904. * @param gradient defines the gradient to use (between 0 and 1)
  62905. * @param factor defines the velocity to affect to the specified gradient
  62906. * @returns the current particle system
  62907. */
  62908. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62909. /**
  62910. * Remove a specific velocity gradient
  62911. * @param gradient defines the gradient to remove
  62912. * @returns the current particle system
  62913. */
  62914. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62915. /**
  62916. * Adds a new limit velocity gradient
  62917. * @param gradient defines the gradient to use (between 0 and 1)
  62918. * @param factor defines the limit velocity value to affect to the specified gradient
  62919. * @returns the current particle system
  62920. */
  62921. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62922. /**
  62923. * Remove a specific limit velocity gradient
  62924. * @param gradient defines the gradient to remove
  62925. * @returns the current particle system
  62926. */
  62927. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62928. /**
  62929. * Adds a new drag gradient
  62930. * @param gradient defines the gradient to use (between 0 and 1)
  62931. * @param factor defines the drag value to affect to the specified gradient
  62932. * @returns the current particle system
  62933. */
  62934. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62935. /**
  62936. * Remove a specific drag gradient
  62937. * @param gradient defines the gradient to remove
  62938. * @returns the current particle system
  62939. */
  62940. removeDragGradient(gradient: number): GPUParticleSystem;
  62941. /**
  62942. * Not supported by GPUParticleSystem
  62943. * @param gradient defines the gradient to use (between 0 and 1)
  62944. * @param factor defines the emit rate value to affect to the specified gradient
  62945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62946. * @returns the current particle system
  62947. */
  62948. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62949. /**
  62950. * Not supported by GPUParticleSystem
  62951. * @param gradient defines the gradient to remove
  62952. * @returns the current particle system
  62953. */
  62954. removeEmitRateGradient(gradient: number): IParticleSystem;
  62955. /**
  62956. * Not supported by GPUParticleSystem
  62957. * @param gradient defines the gradient to use (between 0 and 1)
  62958. * @param factor defines the start size value to affect to the specified gradient
  62959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62960. * @returns the current particle system
  62961. */
  62962. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62963. /**
  62964. * Not supported by GPUParticleSystem
  62965. * @param gradient defines the gradient to remove
  62966. * @returns the current particle system
  62967. */
  62968. removeStartSizeGradient(gradient: number): IParticleSystem;
  62969. /**
  62970. * Not supported by GPUParticleSystem
  62971. * @param gradient defines the gradient to use (between 0 and 1)
  62972. * @param min defines the color remap minimal range
  62973. * @param max defines the color remap maximal range
  62974. * @returns the current particle system
  62975. */
  62976. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62977. /**
  62978. * Not supported by GPUParticleSystem
  62979. * @param gradient defines the gradient to remove
  62980. * @returns the current particle system
  62981. */
  62982. removeColorRemapGradient(): IParticleSystem;
  62983. /**
  62984. * Not supported by GPUParticleSystem
  62985. * @param gradient defines the gradient to use (between 0 and 1)
  62986. * @param min defines the alpha remap minimal range
  62987. * @param max defines the alpha remap maximal range
  62988. * @returns the current particle system
  62989. */
  62990. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62991. /**
  62992. * Not supported by GPUParticleSystem
  62993. * @param gradient defines the gradient to remove
  62994. * @returns the current particle system
  62995. */
  62996. removeAlphaRemapGradient(): IParticleSystem;
  62997. /**
  62998. * Not supported by GPUParticleSystem
  62999. * @param gradient defines the gradient to use (between 0 and 1)
  63000. * @param color defines the color to affect to the specified gradient
  63001. * @returns the current particle system
  63002. */
  63003. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63004. /**
  63005. * Not supported by GPUParticleSystem
  63006. * @param gradient defines the gradient to remove
  63007. * @returns the current particle system
  63008. */
  63009. removeRampGradient(): IParticleSystem;
  63010. /**
  63011. * Not supported by GPUParticleSystem
  63012. * @returns the list of ramp gradients
  63013. */
  63014. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63015. /**
  63016. * Not supported by GPUParticleSystem
  63017. * Gets or sets a boolean indicating that ramp gradients must be used
  63018. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63019. */
  63020. get useRampGradients(): boolean;
  63021. set useRampGradients(value: boolean);
  63022. /**
  63023. * Not supported by GPUParticleSystem
  63024. * @param gradient defines the gradient to use (between 0 and 1)
  63025. * @param factor defines the life time factor to affect to the specified gradient
  63026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63027. * @returns the current particle system
  63028. */
  63029. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63030. /**
  63031. * Not supported by GPUParticleSystem
  63032. * @param gradient defines the gradient to remove
  63033. * @returns the current particle system
  63034. */
  63035. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63036. /**
  63037. * Instantiates a GPU particle system.
  63038. * 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.
  63039. * @param name The name of the particle system
  63040. * @param options The options used to create the system
  63041. * @param scene The scene the particle system belongs to
  63042. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63043. */
  63044. constructor(name: string, options: Partial<{
  63045. capacity: number;
  63046. randomTextureSize: number;
  63047. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63048. protected _reset(): void;
  63049. private _createUpdateVAO;
  63050. private _createRenderVAO;
  63051. private _initialize;
  63052. /** @hidden */
  63053. _recreateUpdateEffect(): void;
  63054. /** @hidden */
  63055. _recreateRenderEffect(): void;
  63056. /**
  63057. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63058. * @param preWarm defines if we are in the pre-warmimg phase
  63059. */
  63060. animate(preWarm?: boolean): void;
  63061. private _createFactorGradientTexture;
  63062. private _createSizeGradientTexture;
  63063. private _createAngularSpeedGradientTexture;
  63064. private _createVelocityGradientTexture;
  63065. private _createLimitVelocityGradientTexture;
  63066. private _createDragGradientTexture;
  63067. private _createColorGradientTexture;
  63068. /**
  63069. * Renders the particle system in its current state
  63070. * @param preWarm defines if the system should only update the particles but not render them
  63071. * @returns the current number of particles
  63072. */
  63073. render(preWarm?: boolean): number;
  63074. /**
  63075. * Rebuilds the particle system
  63076. */
  63077. rebuild(): void;
  63078. private _releaseBuffers;
  63079. private _releaseVAOs;
  63080. /**
  63081. * Disposes the particle system and free the associated resources
  63082. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63083. */
  63084. dispose(disposeTexture?: boolean): void;
  63085. /**
  63086. * Clones the particle system.
  63087. * @param name The name of the cloned object
  63088. * @param newEmitter The new emitter to use
  63089. * @returns the cloned particle system
  63090. */
  63091. clone(name: string, newEmitter: any): GPUParticleSystem;
  63092. /**
  63093. * Serializes the particle system to a JSON object.
  63094. * @returns the JSON object
  63095. */
  63096. serialize(): any;
  63097. /**
  63098. * Parses a JSON object to create a GPU particle system.
  63099. * @param parsedParticleSystem The JSON object to parse
  63100. * @param scene The scene to create the particle system in
  63101. * @param rootUrl The root url to use to load external dependencies like texture
  63102. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63103. * @returns the parsed GPU particle system
  63104. */
  63105. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63106. }
  63107. }
  63108. declare module BABYLON {
  63109. /**
  63110. * Represents a set of particle systems working together to create a specific effect
  63111. */
  63112. export class ParticleSystemSet implements IDisposable {
  63113. /**
  63114. * Gets or sets base Assets URL
  63115. */
  63116. static BaseAssetsUrl: string;
  63117. private _emitterCreationOptions;
  63118. private _emitterNode;
  63119. /**
  63120. * Gets the particle system list
  63121. */
  63122. systems: IParticleSystem[];
  63123. /**
  63124. * Gets the emitter node used with this set
  63125. */
  63126. get emitterNode(): Nullable<TransformNode>;
  63127. /**
  63128. * Creates a new emitter mesh as a sphere
  63129. * @param options defines the options used to create the sphere
  63130. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63131. * @param scene defines the hosting scene
  63132. */
  63133. setEmitterAsSphere(options: {
  63134. diameter: number;
  63135. segments: number;
  63136. color: Color3;
  63137. }, renderingGroupId: number, scene: Scene): void;
  63138. /**
  63139. * Starts all particle systems of the set
  63140. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63141. */
  63142. start(emitter?: AbstractMesh): void;
  63143. /**
  63144. * Release all associated resources
  63145. */
  63146. dispose(): void;
  63147. /**
  63148. * Serialize the set into a JSON compatible object
  63149. * @returns a JSON compatible representation of the set
  63150. */
  63151. serialize(): any;
  63152. /**
  63153. * Parse a new ParticleSystemSet from a serialized source
  63154. * @param data defines a JSON compatible representation of the set
  63155. * @param scene defines the hosting scene
  63156. * @param gpu defines if we want GPU particles or CPU particles
  63157. * @returns a new ParticleSystemSet
  63158. */
  63159. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63160. }
  63161. }
  63162. declare module BABYLON {
  63163. /**
  63164. * This class is made for on one-liner static method to help creating particle system set.
  63165. */
  63166. export class ParticleHelper {
  63167. /**
  63168. * Gets or sets base Assets URL
  63169. */
  63170. static BaseAssetsUrl: string;
  63171. /**
  63172. * Create a default particle system that you can tweak
  63173. * @param emitter defines the emitter to use
  63174. * @param capacity defines the system capacity (default is 500 particles)
  63175. * @param scene defines the hosting scene
  63176. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63177. * @returns the new Particle system
  63178. */
  63179. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63180. /**
  63181. * This is the main static method (one-liner) of this helper to create different particle systems
  63182. * @param type This string represents the type to the particle system to create
  63183. * @param scene The scene where the particle system should live
  63184. * @param gpu If the system will use gpu
  63185. * @returns the ParticleSystemSet created
  63186. */
  63187. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63188. /**
  63189. * Static function used to export a particle system to a ParticleSystemSet variable.
  63190. * Please note that the emitter shape is not exported
  63191. * @param systems defines the particle systems to export
  63192. * @returns the created particle system set
  63193. */
  63194. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63195. }
  63196. }
  63197. declare module BABYLON {
  63198. interface Engine {
  63199. /**
  63200. * Create an effect to use with particle systems.
  63201. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63202. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63203. * @param uniformsNames defines a list of attribute names
  63204. * @param samplers defines an array of string used to represent textures
  63205. * @param defines defines the string containing the defines to use to compile the shaders
  63206. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63207. * @param onCompiled defines a function to call when the effect creation is successful
  63208. * @param onError defines a function to call when the effect creation has failed
  63209. * @returns the new Effect
  63210. */
  63211. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63212. }
  63213. interface Mesh {
  63214. /**
  63215. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63216. * @returns an array of IParticleSystem
  63217. */
  63218. getEmittedParticleSystems(): IParticleSystem[];
  63219. /**
  63220. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63221. * @returns an array of IParticleSystem
  63222. */
  63223. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63224. }
  63225. /**
  63226. * @hidden
  63227. */
  63228. export var _IDoNeedToBeInTheBuild: number;
  63229. }
  63230. declare module BABYLON {
  63231. /** Defines the 4 color options */
  63232. export enum PointColor {
  63233. /** color value */
  63234. Color = 2,
  63235. /** uv value */
  63236. UV = 1,
  63237. /** random value */
  63238. Random = 0,
  63239. /** stated value */
  63240. Stated = 3
  63241. }
  63242. /**
  63243. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63244. * 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.
  63245. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63247. *
  63248. * Full documentation here : TO BE ENTERED
  63249. */
  63250. export class PointsCloudSystem implements IDisposable {
  63251. /**
  63252. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63253. * Example : var p = SPS.particles[i];
  63254. */
  63255. particles: CloudPoint[];
  63256. /**
  63257. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63258. */
  63259. nbParticles: number;
  63260. /**
  63261. * This a counter for your own usage. It's not set by any SPS functions.
  63262. */
  63263. counter: number;
  63264. /**
  63265. * The PCS name. This name is also given to the underlying mesh.
  63266. */
  63267. name: string;
  63268. /**
  63269. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63270. */
  63271. mesh: Mesh;
  63272. /**
  63273. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63274. * Please read :
  63275. */
  63276. vars: any;
  63277. /**
  63278. * @hidden
  63279. */
  63280. _size: number;
  63281. private _scene;
  63282. private _promises;
  63283. private _positions;
  63284. private _indices;
  63285. private _normals;
  63286. private _colors;
  63287. private _uvs;
  63288. private _indices32;
  63289. private _positions32;
  63290. private _colors32;
  63291. private _uvs32;
  63292. private _updatable;
  63293. private _isVisibilityBoxLocked;
  63294. private _alwaysVisible;
  63295. private _groups;
  63296. private _groupCounter;
  63297. private _computeParticleColor;
  63298. private _computeParticleTexture;
  63299. private _computeParticleRotation;
  63300. private _computeBoundingBox;
  63301. private _isReady;
  63302. /**
  63303. * Creates a PCS (Points Cloud System) object
  63304. * @param name (String) is the PCS name, this will be the underlying mesh name
  63305. * @param pointSize (number) is the size for each point
  63306. * @param scene (Scene) is the scene in which the PCS is added
  63307. * @param options defines the options of the PCS e.g.
  63308. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63309. */
  63310. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63311. updatable?: boolean;
  63312. });
  63313. /**
  63314. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63315. * If no points were added to the PCS, the returned mesh is just a single point.
  63316. * @returns a promise for the created mesh
  63317. */
  63318. buildMeshAsync(): Promise<Mesh>;
  63319. /**
  63320. * @hidden
  63321. */
  63322. private _buildMesh;
  63323. private _addParticle;
  63324. private _randomUnitVector;
  63325. private _getColorIndicesForCoord;
  63326. private _setPointsColorOrUV;
  63327. private _colorFromTexture;
  63328. private _calculateDensity;
  63329. /**
  63330. * Adds points to the PCS in random positions within a unit sphere
  63331. * @param nb (positive integer) the number of particles to be created from this model
  63332. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63333. * @returns the number of groups in the system
  63334. */
  63335. addPoints(nb: number, pointFunction?: any): number;
  63336. /**
  63337. * Adds points to the PCS from the surface of the model shape
  63338. * @param mesh is any Mesh object that will be used as a surface model for the points
  63339. * @param nb (positive integer) the number of particles to be created from this model
  63340. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63341. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63342. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63343. * @returns the number of groups in the system
  63344. */
  63345. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63346. /**
  63347. * Adds points to the PCS inside the model shape
  63348. * @param mesh is any Mesh object that will be used as a surface model for the points
  63349. * @param nb (positive integer) the number of particles to be created from this model
  63350. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63351. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63352. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63353. * @returns the number of groups in the system
  63354. */
  63355. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63356. /**
  63357. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63358. * This method calls `updateParticle()` for each particle of the SPS.
  63359. * For an animated SPS, it is usually called within the render loop.
  63360. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63361. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63362. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63363. * @returns the PCS.
  63364. */
  63365. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63366. /**
  63367. * Disposes the PCS.
  63368. */
  63369. dispose(): void;
  63370. /**
  63371. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63372. * doc :
  63373. * @returns the PCS.
  63374. */
  63375. refreshVisibleSize(): PointsCloudSystem;
  63376. /**
  63377. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63378. * @param size the size (float) of the visibility box
  63379. * note : this doesn't lock the PCS mesh bounding box.
  63380. * doc :
  63381. */
  63382. setVisibilityBox(size: number): void;
  63383. /**
  63384. * Gets whether the PCS is always visible or not
  63385. * doc :
  63386. */
  63387. get isAlwaysVisible(): boolean;
  63388. /**
  63389. * Sets the PCS as always visible or not
  63390. * doc :
  63391. */
  63392. set isAlwaysVisible(val: boolean);
  63393. /**
  63394. * Tells to `setParticles()` to compute the particle rotations or not
  63395. * Default value : false. The PCS is faster when it's set to false
  63396. * Note : particle rotations are only applied to parent particles
  63397. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63398. */
  63399. set computeParticleRotation(val: boolean);
  63400. /**
  63401. * Tells to `setParticles()` to compute the particle colors or not.
  63402. * Default value : true. The PCS is faster when it's set to false.
  63403. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63404. */
  63405. set computeParticleColor(val: boolean);
  63406. set computeParticleTexture(val: boolean);
  63407. /**
  63408. * Gets if `setParticles()` computes the particle colors or not.
  63409. * Default value : false. The PCS is faster when it's set to false.
  63410. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63411. */
  63412. get computeParticleColor(): boolean;
  63413. /**
  63414. * Gets if `setParticles()` computes the particle textures or not.
  63415. * Default value : false. The PCS is faster when it's set to false.
  63416. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63417. */
  63418. get computeParticleTexture(): boolean;
  63419. /**
  63420. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63421. */
  63422. set computeBoundingBox(val: boolean);
  63423. /**
  63424. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63425. */
  63426. get computeBoundingBox(): boolean;
  63427. /**
  63428. * This function does nothing. It may be overwritten to set all the particle first values.
  63429. * The PCS doesn't call this function, you may have to call it by your own.
  63430. * doc :
  63431. */
  63432. initParticles(): void;
  63433. /**
  63434. * This function does nothing. It may be overwritten to recycle a particle
  63435. * The PCS doesn't call this function, you can to call it
  63436. * doc :
  63437. * @param particle The particle to recycle
  63438. * @returns the recycled particle
  63439. */
  63440. recycleParticle(particle: CloudPoint): CloudPoint;
  63441. /**
  63442. * Updates a particle : this function should be overwritten by the user.
  63443. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63444. * doc :
  63445. * @example : just set a particle position or velocity and recycle conditions
  63446. * @param particle The particle to update
  63447. * @returns the updated particle
  63448. */
  63449. updateParticle(particle: CloudPoint): CloudPoint;
  63450. /**
  63451. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63452. * This does nothing and may be overwritten by the user.
  63453. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63455. * @param update the boolean update value actually passed to setParticles()
  63456. */
  63457. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63458. /**
  63459. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63460. * This will be passed three parameters.
  63461. * This does nothing and may be overwritten by the user.
  63462. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63463. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63464. * @param update the boolean update value actually passed to setParticles()
  63465. */
  63466. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63467. }
  63468. }
  63469. declare module BABYLON {
  63470. /**
  63471. * Represents one particle of a points cloud system.
  63472. */
  63473. export class CloudPoint {
  63474. /**
  63475. * particle global index
  63476. */
  63477. idx: number;
  63478. /**
  63479. * The color of the particle
  63480. */
  63481. color: Nullable<Color4>;
  63482. /**
  63483. * The world space position of the particle.
  63484. */
  63485. position: Vector3;
  63486. /**
  63487. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63488. */
  63489. rotation: Vector3;
  63490. /**
  63491. * The world space rotation quaternion of the particle.
  63492. */
  63493. rotationQuaternion: Nullable<Quaternion>;
  63494. /**
  63495. * The uv of the particle.
  63496. */
  63497. uv: Nullable<Vector2>;
  63498. /**
  63499. * The current speed of the particle.
  63500. */
  63501. velocity: Vector3;
  63502. /**
  63503. * The pivot point in the particle local space.
  63504. */
  63505. pivot: Vector3;
  63506. /**
  63507. * Must the particle be translated from its pivot point in its local space ?
  63508. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63509. * Default : false
  63510. */
  63511. translateFromPivot: boolean;
  63512. /**
  63513. * Index of this particle in the global "positions" array (Internal use)
  63514. * @hidden
  63515. */
  63516. _pos: number;
  63517. /**
  63518. * @hidden Index of this particle in the global "indices" array (Internal use)
  63519. */
  63520. _ind: number;
  63521. /**
  63522. * Group this particle belongs to
  63523. */
  63524. _group: PointsGroup;
  63525. /**
  63526. * Group id of this particle
  63527. */
  63528. groupId: number;
  63529. /**
  63530. * Index of the particle in its group id (Internal use)
  63531. */
  63532. idxInGroup: number;
  63533. /**
  63534. * @hidden Particle BoundingInfo object (Internal use)
  63535. */
  63536. _boundingInfo: BoundingInfo;
  63537. /**
  63538. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63539. */
  63540. _pcs: PointsCloudSystem;
  63541. /**
  63542. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63543. */
  63544. _stillInvisible: boolean;
  63545. /**
  63546. * @hidden Last computed particle rotation matrix
  63547. */
  63548. _rotationMatrix: number[];
  63549. /**
  63550. * Parent particle Id, if any.
  63551. * Default null.
  63552. */
  63553. parentId: Nullable<number>;
  63554. /**
  63555. * @hidden Internal global position in the PCS.
  63556. */
  63557. _globalPosition: Vector3;
  63558. /**
  63559. * Creates a Point Cloud object.
  63560. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63561. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63562. * @param group (PointsGroup) is the group the particle belongs to
  63563. * @param groupId (integer) is the group identifier in the PCS.
  63564. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63565. * @param pcs defines the PCS it is associated to
  63566. */
  63567. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63568. /**
  63569. * get point size
  63570. */
  63571. get size(): Vector3;
  63572. /**
  63573. * Set point size
  63574. */
  63575. set size(scale: Vector3);
  63576. /**
  63577. * Legacy support, changed quaternion to rotationQuaternion
  63578. */
  63579. get quaternion(): Nullable<Quaternion>;
  63580. /**
  63581. * Legacy support, changed quaternion to rotationQuaternion
  63582. */
  63583. set quaternion(q: Nullable<Quaternion>);
  63584. /**
  63585. * Returns a boolean. True if the particle intersects a mesh, else false
  63586. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63587. * @param target is the object (point or mesh) what the intersection is computed against
  63588. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63589. * @returns true if it intersects
  63590. */
  63591. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63592. /**
  63593. * get the rotation matrix of the particle
  63594. * @hidden
  63595. */
  63596. getRotationMatrix(m: Matrix): void;
  63597. }
  63598. /**
  63599. * Represents a group of points in a points cloud system
  63600. * * PCS internal tool, don't use it manually.
  63601. */
  63602. export class PointsGroup {
  63603. /**
  63604. * The group id
  63605. * @hidden
  63606. */
  63607. groupID: number;
  63608. /**
  63609. * image data for group (internal use)
  63610. * @hidden
  63611. */
  63612. _groupImageData: Nullable<ArrayBufferView>;
  63613. /**
  63614. * Image Width (internal use)
  63615. * @hidden
  63616. */
  63617. _groupImgWidth: number;
  63618. /**
  63619. * Image Height (internal use)
  63620. * @hidden
  63621. */
  63622. _groupImgHeight: number;
  63623. /**
  63624. * Custom position function (internal use)
  63625. * @hidden
  63626. */
  63627. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63628. /**
  63629. * density per facet for surface points
  63630. * @hidden
  63631. */
  63632. _groupDensity: number[];
  63633. /**
  63634. * Only when points are colored by texture carries pointer to texture list array
  63635. * @hidden
  63636. */
  63637. _textureNb: number;
  63638. /**
  63639. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63640. * PCS internal tool, don't use it manually.
  63641. * @hidden
  63642. */
  63643. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63644. }
  63645. }
  63646. declare module BABYLON {
  63647. interface Scene {
  63648. /** @hidden (Backing field) */
  63649. _physicsEngine: Nullable<IPhysicsEngine>;
  63650. /** @hidden */
  63651. _physicsTimeAccumulator: number;
  63652. /**
  63653. * Gets the current physics engine
  63654. * @returns a IPhysicsEngine or null if none attached
  63655. */
  63656. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63657. /**
  63658. * Enables physics to the current scene
  63659. * @param gravity defines the scene's gravity for the physics engine
  63660. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63661. * @return a boolean indicating if the physics engine was initialized
  63662. */
  63663. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63664. /**
  63665. * Disables and disposes the physics engine associated with the scene
  63666. */
  63667. disablePhysicsEngine(): void;
  63668. /**
  63669. * Gets a boolean indicating if there is an active physics engine
  63670. * @returns a boolean indicating if there is an active physics engine
  63671. */
  63672. isPhysicsEnabled(): boolean;
  63673. /**
  63674. * Deletes a physics compound impostor
  63675. * @param compound defines the compound to delete
  63676. */
  63677. deleteCompoundImpostor(compound: any): void;
  63678. /**
  63679. * An event triggered when physic simulation is about to be run
  63680. */
  63681. onBeforePhysicsObservable: Observable<Scene>;
  63682. /**
  63683. * An event triggered when physic simulation has been done
  63684. */
  63685. onAfterPhysicsObservable: Observable<Scene>;
  63686. }
  63687. interface AbstractMesh {
  63688. /** @hidden */
  63689. _physicsImpostor: Nullable<PhysicsImpostor>;
  63690. /**
  63691. * Gets or sets impostor used for physic simulation
  63692. * @see http://doc.babylonjs.com/features/physics_engine
  63693. */
  63694. physicsImpostor: Nullable<PhysicsImpostor>;
  63695. /**
  63696. * Gets the current physics impostor
  63697. * @see http://doc.babylonjs.com/features/physics_engine
  63698. * @returns a physics impostor or null
  63699. */
  63700. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63701. /** Apply a physic impulse to the mesh
  63702. * @param force defines the force to apply
  63703. * @param contactPoint defines where to apply the force
  63704. * @returns the current mesh
  63705. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63706. */
  63707. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63708. /**
  63709. * Creates a physic joint between two meshes
  63710. * @param otherMesh defines the other mesh to use
  63711. * @param pivot1 defines the pivot to use on this mesh
  63712. * @param pivot2 defines the pivot to use on the other mesh
  63713. * @param options defines additional options (can be plugin dependent)
  63714. * @returns the current mesh
  63715. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63716. */
  63717. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63718. /** @hidden */
  63719. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63720. }
  63721. /**
  63722. * Defines the physics engine scene component responsible to manage a physics engine
  63723. */
  63724. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63725. /**
  63726. * The component name helpful to identify the component in the list of scene components.
  63727. */
  63728. readonly name: string;
  63729. /**
  63730. * The scene the component belongs to.
  63731. */
  63732. scene: Scene;
  63733. /**
  63734. * Creates a new instance of the component for the given scene
  63735. * @param scene Defines the scene to register the component in
  63736. */
  63737. constructor(scene: Scene);
  63738. /**
  63739. * Registers the component in a given scene
  63740. */
  63741. register(): void;
  63742. /**
  63743. * Rebuilds the elements related to this component in case of
  63744. * context lost for instance.
  63745. */
  63746. rebuild(): void;
  63747. /**
  63748. * Disposes the component and the associated ressources
  63749. */
  63750. dispose(): void;
  63751. }
  63752. }
  63753. declare module BABYLON {
  63754. /**
  63755. * A helper for physics simulations
  63756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63757. */
  63758. export class PhysicsHelper {
  63759. private _scene;
  63760. private _physicsEngine;
  63761. /**
  63762. * Initializes the Physics helper
  63763. * @param scene Babylon.js scene
  63764. */
  63765. constructor(scene: Scene);
  63766. /**
  63767. * Applies a radial explosion impulse
  63768. * @param origin the origin of the explosion
  63769. * @param radiusOrEventOptions the radius or the options of radial explosion
  63770. * @param strength the explosion strength
  63771. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63772. * @returns A physics radial explosion event, or null
  63773. */
  63774. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63775. /**
  63776. * Applies a radial explosion force
  63777. * @param origin the origin of the explosion
  63778. * @param radiusOrEventOptions the radius or the options of radial explosion
  63779. * @param strength the explosion strength
  63780. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63781. * @returns A physics radial explosion event, or null
  63782. */
  63783. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63784. /**
  63785. * Creates a gravitational field
  63786. * @param origin the origin of the explosion
  63787. * @param radiusOrEventOptions the radius or the options of radial explosion
  63788. * @param strength the explosion strength
  63789. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63790. * @returns A physics gravitational field event, or null
  63791. */
  63792. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63793. /**
  63794. * Creates a physics updraft event
  63795. * @param origin the origin of the updraft
  63796. * @param radiusOrEventOptions the radius or the options of the updraft
  63797. * @param strength the strength of the updraft
  63798. * @param height the height of the updraft
  63799. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63800. * @returns A physics updraft event, or null
  63801. */
  63802. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63803. /**
  63804. * Creates a physics vortex event
  63805. * @param origin the of the vortex
  63806. * @param radiusOrEventOptions the radius or the options of the vortex
  63807. * @param strength the strength of the vortex
  63808. * @param height the height of the vortex
  63809. * @returns a Physics vortex event, or null
  63810. * A physics vortex event or null
  63811. */
  63812. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63813. }
  63814. /**
  63815. * Represents a physics radial explosion event
  63816. */
  63817. class PhysicsRadialExplosionEvent {
  63818. private _scene;
  63819. private _options;
  63820. private _sphere;
  63821. private _dataFetched;
  63822. /**
  63823. * Initializes a radial explosioin event
  63824. * @param _scene BabylonJS scene
  63825. * @param _options The options for the vortex event
  63826. */
  63827. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63828. /**
  63829. * Returns the data related to the radial explosion event (sphere).
  63830. * @returns The radial explosion event data
  63831. */
  63832. getData(): PhysicsRadialExplosionEventData;
  63833. /**
  63834. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63835. * @param impostor A physics imposter
  63836. * @param origin the origin of the explosion
  63837. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63838. */
  63839. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63840. /**
  63841. * Triggers affecterd impostors callbacks
  63842. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63843. */
  63844. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63845. /**
  63846. * Disposes the sphere.
  63847. * @param force Specifies if the sphere should be disposed by force
  63848. */
  63849. dispose(force?: boolean): void;
  63850. /*** Helpers ***/
  63851. private _prepareSphere;
  63852. private _intersectsWithSphere;
  63853. }
  63854. /**
  63855. * Represents a gravitational field event
  63856. */
  63857. class PhysicsGravitationalFieldEvent {
  63858. private _physicsHelper;
  63859. private _scene;
  63860. private _origin;
  63861. private _options;
  63862. private _tickCallback;
  63863. private _sphere;
  63864. private _dataFetched;
  63865. /**
  63866. * Initializes the physics gravitational field event
  63867. * @param _physicsHelper A physics helper
  63868. * @param _scene BabylonJS scene
  63869. * @param _origin The origin position of the gravitational field event
  63870. * @param _options The options for the vortex event
  63871. */
  63872. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63873. /**
  63874. * Returns the data related to the gravitational field event (sphere).
  63875. * @returns A gravitational field event
  63876. */
  63877. getData(): PhysicsGravitationalFieldEventData;
  63878. /**
  63879. * Enables the gravitational field.
  63880. */
  63881. enable(): void;
  63882. /**
  63883. * Disables the gravitational field.
  63884. */
  63885. disable(): void;
  63886. /**
  63887. * Disposes the sphere.
  63888. * @param force The force to dispose from the gravitational field event
  63889. */
  63890. dispose(force?: boolean): void;
  63891. private _tick;
  63892. }
  63893. /**
  63894. * Represents a physics updraft event
  63895. */
  63896. class PhysicsUpdraftEvent {
  63897. private _scene;
  63898. private _origin;
  63899. private _options;
  63900. private _physicsEngine;
  63901. private _originTop;
  63902. private _originDirection;
  63903. private _tickCallback;
  63904. private _cylinder;
  63905. private _cylinderPosition;
  63906. private _dataFetched;
  63907. /**
  63908. * Initializes the physics updraft event
  63909. * @param _scene BabylonJS scene
  63910. * @param _origin The origin position of the updraft
  63911. * @param _options The options for the updraft event
  63912. */
  63913. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63914. /**
  63915. * Returns the data related to the updraft event (cylinder).
  63916. * @returns A physics updraft event
  63917. */
  63918. getData(): PhysicsUpdraftEventData;
  63919. /**
  63920. * Enables the updraft.
  63921. */
  63922. enable(): void;
  63923. /**
  63924. * Disables the updraft.
  63925. */
  63926. disable(): void;
  63927. /**
  63928. * Disposes the cylinder.
  63929. * @param force Specifies if the updraft should be disposed by force
  63930. */
  63931. dispose(force?: boolean): void;
  63932. private getImpostorHitData;
  63933. private _tick;
  63934. /*** Helpers ***/
  63935. private _prepareCylinder;
  63936. private _intersectsWithCylinder;
  63937. }
  63938. /**
  63939. * Represents a physics vortex event
  63940. */
  63941. class PhysicsVortexEvent {
  63942. private _scene;
  63943. private _origin;
  63944. private _options;
  63945. private _physicsEngine;
  63946. private _originTop;
  63947. private _tickCallback;
  63948. private _cylinder;
  63949. private _cylinderPosition;
  63950. private _dataFetched;
  63951. /**
  63952. * Initializes the physics vortex event
  63953. * @param _scene The BabylonJS scene
  63954. * @param _origin The origin position of the vortex
  63955. * @param _options The options for the vortex event
  63956. */
  63957. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63958. /**
  63959. * Returns the data related to the vortex event (cylinder).
  63960. * @returns The physics vortex event data
  63961. */
  63962. getData(): PhysicsVortexEventData;
  63963. /**
  63964. * Enables the vortex.
  63965. */
  63966. enable(): void;
  63967. /**
  63968. * Disables the cortex.
  63969. */
  63970. disable(): void;
  63971. /**
  63972. * Disposes the sphere.
  63973. * @param force
  63974. */
  63975. dispose(force?: boolean): void;
  63976. private getImpostorHitData;
  63977. private _tick;
  63978. /*** Helpers ***/
  63979. private _prepareCylinder;
  63980. private _intersectsWithCylinder;
  63981. }
  63982. /**
  63983. * Options fot the radial explosion event
  63984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63985. */
  63986. export class PhysicsRadialExplosionEventOptions {
  63987. /**
  63988. * The radius of the sphere for the radial explosion.
  63989. */
  63990. radius: number;
  63991. /**
  63992. * The strenth of the explosion.
  63993. */
  63994. strength: number;
  63995. /**
  63996. * The strenght of the force in correspondence to the distance of the affected object
  63997. */
  63998. falloff: PhysicsRadialImpulseFalloff;
  63999. /**
  64000. * Sphere options for the radial explosion.
  64001. */
  64002. sphere: {
  64003. segments: number;
  64004. diameter: number;
  64005. };
  64006. /**
  64007. * Sphere options for the radial explosion.
  64008. */
  64009. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64010. }
  64011. /**
  64012. * Options fot the updraft event
  64013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64014. */
  64015. export class PhysicsUpdraftEventOptions {
  64016. /**
  64017. * The radius of the cylinder for the vortex
  64018. */
  64019. radius: number;
  64020. /**
  64021. * The strenth of the updraft.
  64022. */
  64023. strength: number;
  64024. /**
  64025. * The height of the cylinder for the updraft.
  64026. */
  64027. height: number;
  64028. /**
  64029. * The mode for the the updraft.
  64030. */
  64031. updraftMode: PhysicsUpdraftMode;
  64032. }
  64033. /**
  64034. * Options fot the vortex event
  64035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64036. */
  64037. export class PhysicsVortexEventOptions {
  64038. /**
  64039. * The radius of the cylinder for the vortex
  64040. */
  64041. radius: number;
  64042. /**
  64043. * The strenth of the vortex.
  64044. */
  64045. strength: number;
  64046. /**
  64047. * The height of the cylinder for the vortex.
  64048. */
  64049. height: number;
  64050. /**
  64051. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64052. */
  64053. centripetalForceThreshold: number;
  64054. /**
  64055. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64056. */
  64057. centripetalForceMultiplier: number;
  64058. /**
  64059. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64060. */
  64061. centrifugalForceMultiplier: number;
  64062. /**
  64063. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64064. */
  64065. updraftForceMultiplier: number;
  64066. }
  64067. /**
  64068. * The strenght of the force in correspondence to the distance of the affected object
  64069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64070. */
  64071. export enum PhysicsRadialImpulseFalloff {
  64072. /** Defines that impulse is constant in strength across it's whole radius */
  64073. Constant = 0,
  64074. /** Defines that impulse gets weaker if it's further from the origin */
  64075. Linear = 1
  64076. }
  64077. /**
  64078. * The strength of the force in correspondence to the distance of the affected object
  64079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64080. */
  64081. export enum PhysicsUpdraftMode {
  64082. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64083. Center = 0,
  64084. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64085. Perpendicular = 1
  64086. }
  64087. /**
  64088. * Interface for a physics hit data
  64089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64090. */
  64091. export interface PhysicsHitData {
  64092. /**
  64093. * The force applied at the contact point
  64094. */
  64095. force: Vector3;
  64096. /**
  64097. * The contact point
  64098. */
  64099. contactPoint: Vector3;
  64100. /**
  64101. * The distance from the origin to the contact point
  64102. */
  64103. distanceFromOrigin: number;
  64104. }
  64105. /**
  64106. * Interface for radial explosion event data
  64107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64108. */
  64109. export interface PhysicsRadialExplosionEventData {
  64110. /**
  64111. * A sphere used for the radial explosion event
  64112. */
  64113. sphere: Mesh;
  64114. }
  64115. /**
  64116. * Interface for gravitational field event data
  64117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64118. */
  64119. export interface PhysicsGravitationalFieldEventData {
  64120. /**
  64121. * A sphere mesh used for the gravitational field event
  64122. */
  64123. sphere: Mesh;
  64124. }
  64125. /**
  64126. * Interface for updraft event data
  64127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64128. */
  64129. export interface PhysicsUpdraftEventData {
  64130. /**
  64131. * A cylinder used for the updraft event
  64132. */
  64133. cylinder: Mesh;
  64134. }
  64135. /**
  64136. * Interface for vortex event data
  64137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64138. */
  64139. export interface PhysicsVortexEventData {
  64140. /**
  64141. * A cylinder used for the vortex event
  64142. */
  64143. cylinder: Mesh;
  64144. }
  64145. /**
  64146. * Interface for an affected physics impostor
  64147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64148. */
  64149. export interface PhysicsAffectedImpostorWithData {
  64150. /**
  64151. * The impostor affected by the effect
  64152. */
  64153. impostor: PhysicsImpostor;
  64154. /**
  64155. * The data about the hit/horce from the explosion
  64156. */
  64157. hitData: PhysicsHitData;
  64158. }
  64159. }
  64160. declare module BABYLON {
  64161. /** @hidden */
  64162. export var blackAndWhitePixelShader: {
  64163. name: string;
  64164. shader: string;
  64165. };
  64166. }
  64167. declare module BABYLON {
  64168. /**
  64169. * Post process used to render in black and white
  64170. */
  64171. export class BlackAndWhitePostProcess extends PostProcess {
  64172. /**
  64173. * Linear about to convert he result to black and white (default: 1)
  64174. */
  64175. degree: number;
  64176. /**
  64177. * Creates a black and white post process
  64178. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64179. * @param name The name of the effect.
  64180. * @param options The required width/height ratio to downsize to before computing the render pass.
  64181. * @param camera The camera to apply the render pass to.
  64182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64183. * @param engine The engine which the post process will be applied. (default: current engine)
  64184. * @param reusable If the post process can be reused on the same frame. (default: false)
  64185. */
  64186. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64187. }
  64188. }
  64189. declare module BABYLON {
  64190. /**
  64191. * This represents a set of one or more post processes in Babylon.
  64192. * A post process can be used to apply a shader to a texture after it is rendered.
  64193. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64194. */
  64195. export class PostProcessRenderEffect {
  64196. private _postProcesses;
  64197. private _getPostProcesses;
  64198. private _singleInstance;
  64199. private _cameras;
  64200. private _indicesForCamera;
  64201. /**
  64202. * Name of the effect
  64203. * @hidden
  64204. */
  64205. _name: string;
  64206. /**
  64207. * Instantiates a post process render effect.
  64208. * A post process can be used to apply a shader to a texture after it is rendered.
  64209. * @param engine The engine the effect is tied to
  64210. * @param name The name of the effect
  64211. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64212. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64213. */
  64214. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64215. /**
  64216. * Checks if all the post processes in the effect are supported.
  64217. */
  64218. get isSupported(): boolean;
  64219. /**
  64220. * Updates the current state of the effect
  64221. * @hidden
  64222. */
  64223. _update(): void;
  64224. /**
  64225. * Attaches the effect on cameras
  64226. * @param cameras The camera to attach to.
  64227. * @hidden
  64228. */
  64229. _attachCameras(cameras: Camera): void;
  64230. /**
  64231. * Attaches the effect on cameras
  64232. * @param cameras The camera to attach to.
  64233. * @hidden
  64234. */
  64235. _attachCameras(cameras: Camera[]): void;
  64236. /**
  64237. * Detaches the effect on cameras
  64238. * @param cameras The camera to detatch from.
  64239. * @hidden
  64240. */
  64241. _detachCameras(cameras: Camera): void;
  64242. /**
  64243. * Detatches the effect on cameras
  64244. * @param cameras The camera to detatch from.
  64245. * @hidden
  64246. */
  64247. _detachCameras(cameras: Camera[]): void;
  64248. /**
  64249. * Enables the effect on given cameras
  64250. * @param cameras The camera to enable.
  64251. * @hidden
  64252. */
  64253. _enable(cameras: Camera): void;
  64254. /**
  64255. * Enables the effect on given cameras
  64256. * @param cameras The camera to enable.
  64257. * @hidden
  64258. */
  64259. _enable(cameras: Nullable<Camera[]>): void;
  64260. /**
  64261. * Disables the effect on the given cameras
  64262. * @param cameras The camera to disable.
  64263. * @hidden
  64264. */
  64265. _disable(cameras: Camera): void;
  64266. /**
  64267. * Disables the effect on the given cameras
  64268. * @param cameras The camera to disable.
  64269. * @hidden
  64270. */
  64271. _disable(cameras: Nullable<Camera[]>): void;
  64272. /**
  64273. * Gets a list of the post processes contained in the effect.
  64274. * @param camera The camera to get the post processes on.
  64275. * @returns The list of the post processes in the effect.
  64276. */
  64277. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64278. }
  64279. }
  64280. declare module BABYLON {
  64281. /** @hidden */
  64282. export var extractHighlightsPixelShader: {
  64283. name: string;
  64284. shader: string;
  64285. };
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * 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.
  64290. */
  64291. export class ExtractHighlightsPostProcess extends PostProcess {
  64292. /**
  64293. * The luminance threshold, pixels below this value will be set to black.
  64294. */
  64295. threshold: number;
  64296. /** @hidden */
  64297. _exposure: number;
  64298. /**
  64299. * Post process which has the input texture to be used when performing highlight extraction
  64300. * @hidden
  64301. */
  64302. _inputPostProcess: Nullable<PostProcess>;
  64303. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64304. }
  64305. }
  64306. declare module BABYLON {
  64307. /** @hidden */
  64308. export var bloomMergePixelShader: {
  64309. name: string;
  64310. shader: string;
  64311. };
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64316. */
  64317. export class BloomMergePostProcess extends PostProcess {
  64318. /** Weight of the bloom to be added to the original input. */
  64319. weight: number;
  64320. /**
  64321. * Creates a new instance of @see BloomMergePostProcess
  64322. * @param name The name of the effect.
  64323. * @param originalFromInput Post process which's input will be used for the merge.
  64324. * @param blurred Blurred highlights post process which's output will be used.
  64325. * @param weight Weight of the bloom to be added to the original input.
  64326. * @param options The required width/height ratio to downsize to before computing the render pass.
  64327. * @param camera The camera to apply the render pass to.
  64328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64329. * @param engine The engine which the post process will be applied. (default: current engine)
  64330. * @param reusable If the post process can be reused on the same frame. (default: false)
  64331. * @param textureType Type of textures used when performing the post process. (default: 0)
  64332. * @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)
  64333. */
  64334. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64335. /** Weight of the bloom to be added to the original input. */
  64336. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64337. }
  64338. }
  64339. declare module BABYLON {
  64340. /**
  64341. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64342. */
  64343. export class BloomEffect extends PostProcessRenderEffect {
  64344. private bloomScale;
  64345. /**
  64346. * @hidden Internal
  64347. */
  64348. _effects: Array<PostProcess>;
  64349. /**
  64350. * @hidden Internal
  64351. */
  64352. _downscale: ExtractHighlightsPostProcess;
  64353. private _blurX;
  64354. private _blurY;
  64355. private _merge;
  64356. /**
  64357. * The luminance threshold to find bright areas of the image to bloom.
  64358. */
  64359. get threshold(): number;
  64360. set threshold(value: number);
  64361. /**
  64362. * The strength of the bloom.
  64363. */
  64364. get weight(): number;
  64365. set weight(value: number);
  64366. /**
  64367. * Specifies the size of the bloom blur kernel, relative to the final output size
  64368. */
  64369. get kernel(): number;
  64370. set kernel(value: number);
  64371. /**
  64372. * Creates a new instance of @see BloomEffect
  64373. * @param scene The scene the effect belongs to.
  64374. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64375. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64376. * @param bloomWeight The the strength of bloom.
  64377. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64378. * @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)
  64379. */
  64380. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64381. /**
  64382. * Disposes each of the internal effects for a given camera.
  64383. * @param camera The camera to dispose the effect on.
  64384. */
  64385. disposeEffects(camera: Camera): void;
  64386. /**
  64387. * @hidden Internal
  64388. */
  64389. _updateEffects(): void;
  64390. /**
  64391. * Internal
  64392. * @returns if all the contained post processes are ready.
  64393. * @hidden
  64394. */
  64395. _isReady(): boolean;
  64396. }
  64397. }
  64398. declare module BABYLON {
  64399. /** @hidden */
  64400. export var chromaticAberrationPixelShader: {
  64401. name: string;
  64402. shader: string;
  64403. };
  64404. }
  64405. declare module BABYLON {
  64406. /**
  64407. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64408. */
  64409. export class ChromaticAberrationPostProcess extends PostProcess {
  64410. /**
  64411. * The amount of seperation of rgb channels (default: 30)
  64412. */
  64413. aberrationAmount: number;
  64414. /**
  64415. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64416. */
  64417. radialIntensity: number;
  64418. /**
  64419. * 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))
  64420. */
  64421. direction: Vector2;
  64422. /**
  64423. * 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))
  64424. */
  64425. centerPosition: Vector2;
  64426. /**
  64427. * Creates a new instance ChromaticAberrationPostProcess
  64428. * @param name The name of the effect.
  64429. * @param screenWidth The width of the screen to apply the effect on.
  64430. * @param screenHeight The height of the screen to apply the effect on.
  64431. * @param options The required width/height ratio to downsize to before computing the render pass.
  64432. * @param camera The camera to apply the render pass to.
  64433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64434. * @param engine The engine which the post process will be applied. (default: current engine)
  64435. * @param reusable If the post process can be reused on the same frame. (default: false)
  64436. * @param textureType Type of textures used when performing the post process. (default: 0)
  64437. * @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)
  64438. */
  64439. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64440. }
  64441. }
  64442. declare module BABYLON {
  64443. /** @hidden */
  64444. export var circleOfConfusionPixelShader: {
  64445. name: string;
  64446. shader: string;
  64447. };
  64448. }
  64449. declare module BABYLON {
  64450. /**
  64451. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64452. */
  64453. export class CircleOfConfusionPostProcess extends PostProcess {
  64454. /**
  64455. * 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.
  64456. */
  64457. lensSize: number;
  64458. /**
  64459. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64460. */
  64461. fStop: number;
  64462. /**
  64463. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64464. */
  64465. focusDistance: number;
  64466. /**
  64467. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64468. */
  64469. focalLength: number;
  64470. private _depthTexture;
  64471. /**
  64472. * Creates a new instance CircleOfConfusionPostProcess
  64473. * @param name The name of the effect.
  64474. * @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.
  64475. * @param options The required width/height ratio to downsize to before computing the render pass.
  64476. * @param camera The camera to apply the render pass to.
  64477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64478. * @param engine The engine which the post process will be applied. (default: current engine)
  64479. * @param reusable If the post process can be reused on the same frame. (default: false)
  64480. * @param textureType Type of textures used when performing the post process. (default: 0)
  64481. * @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)
  64482. */
  64483. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64484. /**
  64485. * 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.
  64486. */
  64487. set depthTexture(value: RenderTargetTexture);
  64488. }
  64489. }
  64490. declare module BABYLON {
  64491. /** @hidden */
  64492. export var colorCorrectionPixelShader: {
  64493. name: string;
  64494. shader: string;
  64495. };
  64496. }
  64497. declare module BABYLON {
  64498. /**
  64499. *
  64500. * This post-process allows the modification of rendered colors by using
  64501. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64502. *
  64503. * The object needs to be provided an url to a texture containing the color
  64504. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64505. * Use an image editing software to tweak the LUT to match your needs.
  64506. *
  64507. * For an example of a color LUT, see here:
  64508. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64509. * For explanations on color grading, see here:
  64510. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64511. *
  64512. */
  64513. export class ColorCorrectionPostProcess extends PostProcess {
  64514. private _colorTableTexture;
  64515. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64516. }
  64517. }
  64518. declare module BABYLON {
  64519. /** @hidden */
  64520. export var convolutionPixelShader: {
  64521. name: string;
  64522. shader: string;
  64523. };
  64524. }
  64525. declare module BABYLON {
  64526. /**
  64527. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64528. * input texture to perform effects such as edge detection or sharpening
  64529. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64530. */
  64531. export class ConvolutionPostProcess extends PostProcess {
  64532. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64533. kernel: number[];
  64534. /**
  64535. * Creates a new instance ConvolutionPostProcess
  64536. * @param name The name of the effect.
  64537. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64538. * @param options The required width/height ratio to downsize to before computing the render pass.
  64539. * @param camera The camera to apply the render pass to.
  64540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64541. * @param engine The engine which the post process will be applied. (default: current engine)
  64542. * @param reusable If the post process can be reused on the same frame. (default: false)
  64543. * @param textureType Type of textures used when performing the post process. (default: 0)
  64544. */
  64545. constructor(name: string,
  64546. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64547. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64548. /**
  64549. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64550. */
  64551. static EdgeDetect0Kernel: number[];
  64552. /**
  64553. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64554. */
  64555. static EdgeDetect1Kernel: number[];
  64556. /**
  64557. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64558. */
  64559. static EdgeDetect2Kernel: number[];
  64560. /**
  64561. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64562. */
  64563. static SharpenKernel: number[];
  64564. /**
  64565. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64566. */
  64567. static EmbossKernel: number[];
  64568. /**
  64569. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64570. */
  64571. static GaussianKernel: number[];
  64572. }
  64573. }
  64574. declare module BABYLON {
  64575. /**
  64576. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64577. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64578. * based on samples that have a large difference in distance than the center pixel.
  64579. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64580. */
  64581. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64582. direction: Vector2;
  64583. /**
  64584. * Creates a new instance CircleOfConfusionPostProcess
  64585. * @param name The name of the effect.
  64586. * @param scene The scene the effect belongs to.
  64587. * @param direction The direction the blur should be applied.
  64588. * @param kernel The size of the kernel used to blur.
  64589. * @param options The required width/height ratio to downsize to before computing the render pass.
  64590. * @param camera The camera to apply the render pass to.
  64591. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64592. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64594. * @param engine The engine which the post process will be applied. (default: current engine)
  64595. * @param reusable If the post process can be reused on the same frame. (default: false)
  64596. * @param textureType Type of textures used when performing the post process. (default: 0)
  64597. * @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)
  64598. */
  64599. 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);
  64600. }
  64601. }
  64602. declare module BABYLON {
  64603. /** @hidden */
  64604. export var depthOfFieldMergePixelShader: {
  64605. name: string;
  64606. shader: string;
  64607. };
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * Options to be set when merging outputs from the default pipeline.
  64612. */
  64613. export class DepthOfFieldMergePostProcessOptions {
  64614. /**
  64615. * The original image to merge on top of
  64616. */
  64617. originalFromInput: PostProcess;
  64618. /**
  64619. * Parameters to perform the merge of the depth of field effect
  64620. */
  64621. depthOfField?: {
  64622. circleOfConfusion: PostProcess;
  64623. blurSteps: Array<PostProcess>;
  64624. };
  64625. /**
  64626. * Parameters to perform the merge of bloom effect
  64627. */
  64628. bloom?: {
  64629. blurred: PostProcess;
  64630. weight: number;
  64631. };
  64632. }
  64633. /**
  64634. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64635. */
  64636. export class DepthOfFieldMergePostProcess extends PostProcess {
  64637. private blurSteps;
  64638. /**
  64639. * Creates a new instance of DepthOfFieldMergePostProcess
  64640. * @param name The name of the effect.
  64641. * @param originalFromInput Post process which's input will be used for the merge.
  64642. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64643. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64644. * @param options The required width/height ratio to downsize to before computing the render pass.
  64645. * @param camera The camera to apply the render pass to.
  64646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64647. * @param engine The engine which the post process will be applied. (default: current engine)
  64648. * @param reusable If the post process can be reused on the same frame. (default: false)
  64649. * @param textureType Type of textures used when performing the post process. (default: 0)
  64650. * @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)
  64651. */
  64652. 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);
  64653. /**
  64654. * Updates the effect with the current post process compile time values and recompiles the shader.
  64655. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64656. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64657. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64658. * @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
  64659. * @param onCompiled Called when the shader has been compiled.
  64660. * @param onError Called if there is an error when compiling a shader.
  64661. */
  64662. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64663. }
  64664. }
  64665. declare module BABYLON {
  64666. /**
  64667. * Specifies the level of max blur that should be applied when using the depth of field effect
  64668. */
  64669. export enum DepthOfFieldEffectBlurLevel {
  64670. /**
  64671. * Subtle blur
  64672. */
  64673. Low = 0,
  64674. /**
  64675. * Medium blur
  64676. */
  64677. Medium = 1,
  64678. /**
  64679. * Large blur
  64680. */
  64681. High = 2
  64682. }
  64683. /**
  64684. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64685. */
  64686. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64687. private _circleOfConfusion;
  64688. /**
  64689. * @hidden Internal, blurs from high to low
  64690. */
  64691. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64692. private _depthOfFieldBlurY;
  64693. private _dofMerge;
  64694. /**
  64695. * @hidden Internal post processes in depth of field effect
  64696. */
  64697. _effects: Array<PostProcess>;
  64698. /**
  64699. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64700. */
  64701. set focalLength(value: number);
  64702. get focalLength(): number;
  64703. /**
  64704. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64705. */
  64706. set fStop(value: number);
  64707. get fStop(): number;
  64708. /**
  64709. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64710. */
  64711. set focusDistance(value: number);
  64712. get focusDistance(): number;
  64713. /**
  64714. * 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.
  64715. */
  64716. set lensSize(value: number);
  64717. get lensSize(): number;
  64718. /**
  64719. * Creates a new instance DepthOfFieldEffect
  64720. * @param scene The scene the effect belongs to.
  64721. * @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.
  64722. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64723. * @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)
  64724. */
  64725. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64726. /**
  64727. * Get the current class name of the current effet
  64728. * @returns "DepthOfFieldEffect"
  64729. */
  64730. getClassName(): string;
  64731. /**
  64732. * 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.
  64733. */
  64734. set depthTexture(value: RenderTargetTexture);
  64735. /**
  64736. * Disposes each of the internal effects for a given camera.
  64737. * @param camera The camera to dispose the effect on.
  64738. */
  64739. disposeEffects(camera: Camera): void;
  64740. /**
  64741. * @hidden Internal
  64742. */
  64743. _updateEffects(): void;
  64744. /**
  64745. * Internal
  64746. * @returns if all the contained post processes are ready.
  64747. * @hidden
  64748. */
  64749. _isReady(): boolean;
  64750. }
  64751. }
  64752. declare module BABYLON {
  64753. /** @hidden */
  64754. export var displayPassPixelShader: {
  64755. name: string;
  64756. shader: string;
  64757. };
  64758. }
  64759. declare module BABYLON {
  64760. /**
  64761. * DisplayPassPostProcess which produces an output the same as it's input
  64762. */
  64763. export class DisplayPassPostProcess extends PostProcess {
  64764. /**
  64765. * Creates the DisplayPassPostProcess
  64766. * @param name The name of the effect.
  64767. * @param options The required width/height ratio to downsize to before computing the render pass.
  64768. * @param camera The camera to apply the render pass to.
  64769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64770. * @param engine The engine which the post process will be applied. (default: current engine)
  64771. * @param reusable If the post process can be reused on the same frame. (default: false)
  64772. */
  64773. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64774. }
  64775. }
  64776. declare module BABYLON {
  64777. /** @hidden */
  64778. export var filterPixelShader: {
  64779. name: string;
  64780. shader: string;
  64781. };
  64782. }
  64783. declare module BABYLON {
  64784. /**
  64785. * Applies a kernel filter to the image
  64786. */
  64787. export class FilterPostProcess extends PostProcess {
  64788. /** The matrix to be applied to the image */
  64789. kernelMatrix: Matrix;
  64790. /**
  64791. *
  64792. * @param name The name of the effect.
  64793. * @param kernelMatrix The matrix to be applied to the image
  64794. * @param options The required width/height ratio to downsize to before computing the render pass.
  64795. * @param camera The camera to apply the render pass to.
  64796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64797. * @param engine The engine which the post process will be applied. (default: current engine)
  64798. * @param reusable If the post process can be reused on the same frame. (default: false)
  64799. */
  64800. constructor(name: string,
  64801. /** The matrix to be applied to the image */
  64802. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /** @hidden */
  64807. export var fxaaPixelShader: {
  64808. name: string;
  64809. shader: string;
  64810. };
  64811. }
  64812. declare module BABYLON {
  64813. /** @hidden */
  64814. export var fxaaVertexShader: {
  64815. name: string;
  64816. shader: string;
  64817. };
  64818. }
  64819. declare module BABYLON {
  64820. /**
  64821. * Fxaa post process
  64822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64823. */
  64824. export class FxaaPostProcess extends PostProcess {
  64825. /** @hidden */
  64826. texelWidth: number;
  64827. /** @hidden */
  64828. texelHeight: number;
  64829. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64830. private _getDefines;
  64831. }
  64832. }
  64833. declare module BABYLON {
  64834. /** @hidden */
  64835. export var grainPixelShader: {
  64836. name: string;
  64837. shader: string;
  64838. };
  64839. }
  64840. declare module BABYLON {
  64841. /**
  64842. * The GrainPostProcess adds noise to the image at mid luminance levels
  64843. */
  64844. export class GrainPostProcess extends PostProcess {
  64845. /**
  64846. * The intensity of the grain added (default: 30)
  64847. */
  64848. intensity: number;
  64849. /**
  64850. * If the grain should be randomized on every frame
  64851. */
  64852. animated: boolean;
  64853. /**
  64854. * Creates a new instance of @see GrainPostProcess
  64855. * @param name The name of the effect.
  64856. * @param options The required width/height ratio to downsize to before computing the render pass.
  64857. * @param camera The camera to apply the render pass to.
  64858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64859. * @param engine The engine which the post process will be applied. (default: current engine)
  64860. * @param reusable If the post process can be reused on the same frame. (default: false)
  64861. * @param textureType Type of textures used when performing the post process. (default: 0)
  64862. * @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)
  64863. */
  64864. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64865. }
  64866. }
  64867. declare module BABYLON {
  64868. /** @hidden */
  64869. export var highlightsPixelShader: {
  64870. name: string;
  64871. shader: string;
  64872. };
  64873. }
  64874. declare module BABYLON {
  64875. /**
  64876. * Extracts highlights from the image
  64877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64878. */
  64879. export class HighlightsPostProcess extends PostProcess {
  64880. /**
  64881. * Extracts highlights from the image
  64882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64883. * @param name The name of the effect.
  64884. * @param options The required width/height ratio to downsize to before computing the render pass.
  64885. * @param camera The camera to apply the render pass to.
  64886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64887. * @param engine The engine which the post process will be applied. (default: current engine)
  64888. * @param reusable If the post process can be reused on the same frame. (default: false)
  64889. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64890. */
  64891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64892. }
  64893. }
  64894. declare module BABYLON {
  64895. /** @hidden */
  64896. export var mrtFragmentDeclaration: {
  64897. name: string;
  64898. shader: string;
  64899. };
  64900. }
  64901. declare module BABYLON {
  64902. /** @hidden */
  64903. export var geometryPixelShader: {
  64904. name: string;
  64905. shader: string;
  64906. };
  64907. }
  64908. declare module BABYLON {
  64909. /** @hidden */
  64910. export var geometryVertexShader: {
  64911. name: string;
  64912. shader: string;
  64913. };
  64914. }
  64915. declare module BABYLON {
  64916. /** @hidden */
  64917. interface ISavedTransformationMatrix {
  64918. world: Matrix;
  64919. viewProjection: Matrix;
  64920. }
  64921. /**
  64922. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64923. */
  64924. export class GeometryBufferRenderer {
  64925. /**
  64926. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64927. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64928. */
  64929. static readonly POSITION_TEXTURE_TYPE: number;
  64930. /**
  64931. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64932. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64933. */
  64934. static readonly VELOCITY_TEXTURE_TYPE: number;
  64935. /**
  64936. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64937. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64938. */
  64939. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64940. /**
  64941. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64942. * in order to compute objects velocities when enableVelocity is set to "true"
  64943. * @hidden
  64944. */
  64945. _previousTransformationMatrices: {
  64946. [index: number]: ISavedTransformationMatrix;
  64947. };
  64948. /**
  64949. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64950. * in order to compute objects velocities when enableVelocity is set to "true"
  64951. * @hidden
  64952. */
  64953. _previousBonesTransformationMatrices: {
  64954. [index: number]: Float32Array;
  64955. };
  64956. /**
  64957. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64958. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64959. */
  64960. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64961. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64962. renderTransparentMeshes: boolean;
  64963. private _scene;
  64964. private _multiRenderTarget;
  64965. private _ratio;
  64966. private _enablePosition;
  64967. private _enableVelocity;
  64968. private _enableReflectivity;
  64969. private _positionIndex;
  64970. private _velocityIndex;
  64971. private _reflectivityIndex;
  64972. protected _effect: Effect;
  64973. protected _cachedDefines: string;
  64974. /**
  64975. * Set the render list (meshes to be rendered) used in the G buffer.
  64976. */
  64977. set renderList(meshes: Mesh[]);
  64978. /**
  64979. * Gets wether or not G buffer are supported by the running hardware.
  64980. * This requires draw buffer supports
  64981. */
  64982. get isSupported(): boolean;
  64983. /**
  64984. * Returns the index of the given texture type in the G-Buffer textures array
  64985. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64986. * @returns the index of the given texture type in the G-Buffer textures array
  64987. */
  64988. getTextureIndex(textureType: number): number;
  64989. /**
  64990. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64991. */
  64992. get enablePosition(): boolean;
  64993. /**
  64994. * Sets whether or not objects positions are enabled for the G buffer.
  64995. */
  64996. set enablePosition(enable: boolean);
  64997. /**
  64998. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64999. */
  65000. get enableVelocity(): boolean;
  65001. /**
  65002. * Sets wether or not objects velocities are enabled for the G buffer.
  65003. */
  65004. set enableVelocity(enable: boolean);
  65005. /**
  65006. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65007. */
  65008. get enableReflectivity(): boolean;
  65009. /**
  65010. * Sets wether or not objects roughness are enabled for the G buffer.
  65011. */
  65012. set enableReflectivity(enable: boolean);
  65013. /**
  65014. * Gets the scene associated with the buffer.
  65015. */
  65016. get scene(): Scene;
  65017. /**
  65018. * Gets the ratio used by the buffer during its creation.
  65019. * How big is the buffer related to the main canvas.
  65020. */
  65021. get ratio(): number;
  65022. /** @hidden */
  65023. static _SceneComponentInitialization: (scene: Scene) => void;
  65024. /**
  65025. * Creates a new G Buffer for the scene
  65026. * @param scene The scene the buffer belongs to
  65027. * @param ratio How big is the buffer related to the main canvas.
  65028. */
  65029. constructor(scene: Scene, ratio?: number);
  65030. /**
  65031. * Checks wether everything is ready to render a submesh to the G buffer.
  65032. * @param subMesh the submesh to check readiness for
  65033. * @param useInstances is the mesh drawn using instance or not
  65034. * @returns true if ready otherwise false
  65035. */
  65036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65037. /**
  65038. * Gets the current underlying G Buffer.
  65039. * @returns the buffer
  65040. */
  65041. getGBuffer(): MultiRenderTarget;
  65042. /**
  65043. * Gets the number of samples used to render the buffer (anti aliasing).
  65044. */
  65045. get samples(): number;
  65046. /**
  65047. * Sets the number of samples used to render the buffer (anti aliasing).
  65048. */
  65049. set samples(value: number);
  65050. /**
  65051. * Disposes the renderer and frees up associated resources.
  65052. */
  65053. dispose(): void;
  65054. protected _createRenderTargets(): void;
  65055. private _copyBonesTransformationMatrices;
  65056. }
  65057. }
  65058. declare module BABYLON {
  65059. interface Scene {
  65060. /** @hidden (Backing field) */
  65061. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65062. /**
  65063. * Gets or Sets the current geometry buffer associated to the scene.
  65064. */
  65065. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65066. /**
  65067. * Enables a GeometryBufferRender and associates it with the scene
  65068. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65069. * @returns the GeometryBufferRenderer
  65070. */
  65071. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65072. /**
  65073. * Disables the GeometryBufferRender associated with the scene
  65074. */
  65075. disableGeometryBufferRenderer(): void;
  65076. }
  65077. /**
  65078. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65079. * in several rendering techniques.
  65080. */
  65081. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65082. /**
  65083. * The component name helpful to identify the component in the list of scene components.
  65084. */
  65085. readonly name: string;
  65086. /**
  65087. * The scene the component belongs to.
  65088. */
  65089. scene: Scene;
  65090. /**
  65091. * Creates a new instance of the component for the given scene
  65092. * @param scene Defines the scene to register the component in
  65093. */
  65094. constructor(scene: Scene);
  65095. /**
  65096. * Registers the component in a given scene
  65097. */
  65098. register(): void;
  65099. /**
  65100. * Rebuilds the elements related to this component in case of
  65101. * context lost for instance.
  65102. */
  65103. rebuild(): void;
  65104. /**
  65105. * Disposes the component and the associated ressources
  65106. */
  65107. dispose(): void;
  65108. private _gatherRenderTargets;
  65109. }
  65110. }
  65111. declare module BABYLON {
  65112. /** @hidden */
  65113. export var motionBlurPixelShader: {
  65114. name: string;
  65115. shader: string;
  65116. };
  65117. }
  65118. declare module BABYLON {
  65119. /**
  65120. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65121. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65122. * As an example, all you have to do is to create the post-process:
  65123. * var mb = new BABYLON.MotionBlurPostProcess(
  65124. * 'mb', // The name of the effect.
  65125. * scene, // The scene containing the objects to blur according to their velocity.
  65126. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65127. * camera // The camera to apply the render pass to.
  65128. * );
  65129. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65130. */
  65131. export class MotionBlurPostProcess extends PostProcess {
  65132. /**
  65133. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65134. */
  65135. motionStrength: number;
  65136. /**
  65137. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65138. */
  65139. get motionBlurSamples(): number;
  65140. /**
  65141. * Sets the number of iterations to be used for motion blur quality
  65142. */
  65143. set motionBlurSamples(samples: number);
  65144. private _motionBlurSamples;
  65145. private _geometryBufferRenderer;
  65146. /**
  65147. * Creates a new instance MotionBlurPostProcess
  65148. * @param name The name of the effect.
  65149. * @param scene The scene containing the objects to blur according to their velocity.
  65150. * @param options The required width/height ratio to downsize to before computing the render pass.
  65151. * @param camera The camera to apply the render pass to.
  65152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65153. * @param engine The engine which the post process will be applied. (default: current engine)
  65154. * @param reusable If the post process can be reused on the same frame. (default: false)
  65155. * @param textureType Type of textures used when performing the post process. (default: 0)
  65156. * @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)
  65157. */
  65158. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65159. /**
  65160. * Excludes the given skinned mesh from computing bones velocities.
  65161. * 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.
  65162. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65163. */
  65164. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65165. /**
  65166. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65167. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65168. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65169. */
  65170. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65171. /**
  65172. * Disposes the post process.
  65173. * @param camera The camera to dispose the post process on.
  65174. */
  65175. dispose(camera?: Camera): void;
  65176. }
  65177. }
  65178. declare module BABYLON {
  65179. /** @hidden */
  65180. export var refractionPixelShader: {
  65181. name: string;
  65182. shader: string;
  65183. };
  65184. }
  65185. declare module BABYLON {
  65186. /**
  65187. * Post process which applies a refractin texture
  65188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65189. */
  65190. export class RefractionPostProcess extends PostProcess {
  65191. /** the base color of the refraction (used to taint the rendering) */
  65192. color: Color3;
  65193. /** simulated refraction depth */
  65194. depth: number;
  65195. /** the coefficient of the base color (0 to remove base color tainting) */
  65196. colorLevel: number;
  65197. private _refTexture;
  65198. private _ownRefractionTexture;
  65199. /**
  65200. * Gets or sets the refraction texture
  65201. * Please note that you are responsible for disposing the texture if you set it manually
  65202. */
  65203. get refractionTexture(): Texture;
  65204. set refractionTexture(value: Texture);
  65205. /**
  65206. * Initializes the RefractionPostProcess
  65207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65208. * @param name The name of the effect.
  65209. * @param refractionTextureUrl Url of the refraction texture to use
  65210. * @param color the base color of the refraction (used to taint the rendering)
  65211. * @param depth simulated refraction depth
  65212. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65213. * @param camera The camera to apply the render pass to.
  65214. * @param options The required width/height ratio to downsize to before computing the render pass.
  65215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65216. * @param engine The engine which the post process will be applied. (default: current engine)
  65217. * @param reusable If the post process can be reused on the same frame. (default: false)
  65218. */
  65219. constructor(name: string, refractionTextureUrl: string,
  65220. /** the base color of the refraction (used to taint the rendering) */
  65221. color: Color3,
  65222. /** simulated refraction depth */
  65223. depth: number,
  65224. /** the coefficient of the base color (0 to remove base color tainting) */
  65225. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65226. /**
  65227. * Disposes of the post process
  65228. * @param camera Camera to dispose post process on
  65229. */
  65230. dispose(camera: Camera): void;
  65231. }
  65232. }
  65233. declare module BABYLON {
  65234. /** @hidden */
  65235. export var sharpenPixelShader: {
  65236. name: string;
  65237. shader: string;
  65238. };
  65239. }
  65240. declare module BABYLON {
  65241. /**
  65242. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65243. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65244. */
  65245. export class SharpenPostProcess extends PostProcess {
  65246. /**
  65247. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65248. */
  65249. colorAmount: number;
  65250. /**
  65251. * How much sharpness should be applied (default: 0.3)
  65252. */
  65253. edgeAmount: number;
  65254. /**
  65255. * Creates a new instance ConvolutionPostProcess
  65256. * @param name The name of the effect.
  65257. * @param options The required width/height ratio to downsize to before computing the render pass.
  65258. * @param camera The camera to apply the render pass to.
  65259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65260. * @param engine The engine which the post process will be applied. (default: current engine)
  65261. * @param reusable If the post process can be reused on the same frame. (default: false)
  65262. * @param textureType Type of textures used when performing the post process. (default: 0)
  65263. * @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)
  65264. */
  65265. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65266. }
  65267. }
  65268. declare module BABYLON {
  65269. /**
  65270. * PostProcessRenderPipeline
  65271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65272. */
  65273. export class PostProcessRenderPipeline {
  65274. private engine;
  65275. private _renderEffects;
  65276. private _renderEffectsForIsolatedPass;
  65277. /**
  65278. * List of inspectable custom properties (used by the Inspector)
  65279. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65280. */
  65281. inspectableCustomProperties: IInspectable[];
  65282. /**
  65283. * @hidden
  65284. */
  65285. protected _cameras: Camera[];
  65286. /** @hidden */
  65287. _name: string;
  65288. /**
  65289. * Gets pipeline name
  65290. */
  65291. get name(): string;
  65292. /** Gets the list of attached cameras */
  65293. get cameras(): Camera[];
  65294. /**
  65295. * Initializes a PostProcessRenderPipeline
  65296. * @param engine engine to add the pipeline to
  65297. * @param name name of the pipeline
  65298. */
  65299. constructor(engine: Engine, name: string);
  65300. /**
  65301. * Gets the class name
  65302. * @returns "PostProcessRenderPipeline"
  65303. */
  65304. getClassName(): string;
  65305. /**
  65306. * If all the render effects in the pipeline are supported
  65307. */
  65308. get isSupported(): boolean;
  65309. /**
  65310. * Adds an effect to the pipeline
  65311. * @param renderEffect the effect to add
  65312. */
  65313. addEffect(renderEffect: PostProcessRenderEffect): void;
  65314. /** @hidden */
  65315. _rebuild(): void;
  65316. /** @hidden */
  65317. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65318. /** @hidden */
  65319. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65320. /** @hidden */
  65321. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65322. /** @hidden */
  65323. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65324. /** @hidden */
  65325. _attachCameras(cameras: Camera, unique: boolean): void;
  65326. /** @hidden */
  65327. _attachCameras(cameras: Camera[], unique: boolean): void;
  65328. /** @hidden */
  65329. _detachCameras(cameras: Camera): void;
  65330. /** @hidden */
  65331. _detachCameras(cameras: Nullable<Camera[]>): void;
  65332. /** @hidden */
  65333. _update(): void;
  65334. /** @hidden */
  65335. _reset(): void;
  65336. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65337. /**
  65338. * Disposes of the pipeline
  65339. */
  65340. dispose(): void;
  65341. }
  65342. }
  65343. declare module BABYLON {
  65344. /**
  65345. * PostProcessRenderPipelineManager class
  65346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65347. */
  65348. export class PostProcessRenderPipelineManager {
  65349. private _renderPipelines;
  65350. /**
  65351. * Initializes a PostProcessRenderPipelineManager
  65352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65353. */
  65354. constructor();
  65355. /**
  65356. * Gets the list of supported render pipelines
  65357. */
  65358. get supportedPipelines(): PostProcessRenderPipeline[];
  65359. /**
  65360. * Adds a pipeline to the manager
  65361. * @param renderPipeline The pipeline to add
  65362. */
  65363. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65364. /**
  65365. * Attaches a camera to the pipeline
  65366. * @param renderPipelineName The name of the pipeline to attach to
  65367. * @param cameras the camera to attach
  65368. * @param unique if the camera can be attached multiple times to the pipeline
  65369. */
  65370. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65371. /**
  65372. * Detaches a camera from the pipeline
  65373. * @param renderPipelineName The name of the pipeline to detach from
  65374. * @param cameras the camera to detach
  65375. */
  65376. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65377. /**
  65378. * Enables an effect by name on a pipeline
  65379. * @param renderPipelineName the name of the pipeline to enable the effect in
  65380. * @param renderEffectName the name of the effect to enable
  65381. * @param cameras the cameras that the effect should be enabled on
  65382. */
  65383. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65384. /**
  65385. * Disables an effect by name on a pipeline
  65386. * @param renderPipelineName the name of the pipeline to disable the effect in
  65387. * @param renderEffectName the name of the effect to disable
  65388. * @param cameras the cameras that the effect should be disabled on
  65389. */
  65390. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65391. /**
  65392. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65393. */
  65394. update(): void;
  65395. /** @hidden */
  65396. _rebuild(): void;
  65397. /**
  65398. * Disposes of the manager and pipelines
  65399. */
  65400. dispose(): void;
  65401. }
  65402. }
  65403. declare module BABYLON {
  65404. interface Scene {
  65405. /** @hidden (Backing field) */
  65406. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65407. /**
  65408. * Gets the postprocess render pipeline manager
  65409. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65410. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65411. */
  65412. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65413. }
  65414. /**
  65415. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65416. */
  65417. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65418. /**
  65419. * The component name helpfull to identify the component in the list of scene components.
  65420. */
  65421. readonly name: string;
  65422. /**
  65423. * The scene the component belongs to.
  65424. */
  65425. scene: Scene;
  65426. /**
  65427. * Creates a new instance of the component for the given scene
  65428. * @param scene Defines the scene to register the component in
  65429. */
  65430. constructor(scene: Scene);
  65431. /**
  65432. * Registers the component in a given scene
  65433. */
  65434. register(): void;
  65435. /**
  65436. * Rebuilds the elements related to this component in case of
  65437. * context lost for instance.
  65438. */
  65439. rebuild(): void;
  65440. /**
  65441. * Disposes the component and the associated ressources
  65442. */
  65443. dispose(): void;
  65444. private _gatherRenderTargets;
  65445. }
  65446. }
  65447. declare module BABYLON {
  65448. /**
  65449. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65450. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65451. */
  65452. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65453. private _scene;
  65454. private _camerasToBeAttached;
  65455. /**
  65456. * ID of the sharpen post process,
  65457. */
  65458. private readonly SharpenPostProcessId;
  65459. /**
  65460. * @ignore
  65461. * ID of the image processing post process;
  65462. */
  65463. readonly ImageProcessingPostProcessId: string;
  65464. /**
  65465. * @ignore
  65466. * ID of the Fast Approximate Anti-Aliasing post process;
  65467. */
  65468. readonly FxaaPostProcessId: string;
  65469. /**
  65470. * ID of the chromatic aberration post process,
  65471. */
  65472. private readonly ChromaticAberrationPostProcessId;
  65473. /**
  65474. * ID of the grain post process
  65475. */
  65476. private readonly GrainPostProcessId;
  65477. /**
  65478. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65479. */
  65480. sharpen: SharpenPostProcess;
  65481. private _sharpenEffect;
  65482. private bloom;
  65483. /**
  65484. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65485. */
  65486. depthOfField: DepthOfFieldEffect;
  65487. /**
  65488. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65489. */
  65490. fxaa: FxaaPostProcess;
  65491. /**
  65492. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65493. */
  65494. imageProcessing: ImageProcessingPostProcess;
  65495. /**
  65496. * Chromatic aberration post process which will shift rgb colors in the image
  65497. */
  65498. chromaticAberration: ChromaticAberrationPostProcess;
  65499. private _chromaticAberrationEffect;
  65500. /**
  65501. * Grain post process which add noise to the image
  65502. */
  65503. grain: GrainPostProcess;
  65504. private _grainEffect;
  65505. /**
  65506. * Glow post process which adds a glow to emissive areas of the image
  65507. */
  65508. private _glowLayer;
  65509. /**
  65510. * Animations which can be used to tweak settings over a period of time
  65511. */
  65512. animations: Animation[];
  65513. private _imageProcessingConfigurationObserver;
  65514. private _sharpenEnabled;
  65515. private _bloomEnabled;
  65516. private _depthOfFieldEnabled;
  65517. private _depthOfFieldBlurLevel;
  65518. private _fxaaEnabled;
  65519. private _imageProcessingEnabled;
  65520. private _defaultPipelineTextureType;
  65521. private _bloomScale;
  65522. private _chromaticAberrationEnabled;
  65523. private _grainEnabled;
  65524. private _buildAllowed;
  65525. /**
  65526. * Gets active scene
  65527. */
  65528. get scene(): Scene;
  65529. /**
  65530. * Enable or disable the sharpen process from the pipeline
  65531. */
  65532. set sharpenEnabled(enabled: boolean);
  65533. get sharpenEnabled(): boolean;
  65534. private _resizeObserver;
  65535. private _hardwareScaleLevel;
  65536. private _bloomKernel;
  65537. /**
  65538. * Specifies the size of the bloom blur kernel, relative to the final output size
  65539. */
  65540. get bloomKernel(): number;
  65541. set bloomKernel(value: number);
  65542. /**
  65543. * Specifies the weight of the bloom in the final rendering
  65544. */
  65545. private _bloomWeight;
  65546. /**
  65547. * Specifies the luma threshold for the area that will be blurred by the bloom
  65548. */
  65549. private _bloomThreshold;
  65550. private _hdr;
  65551. /**
  65552. * The strength of the bloom.
  65553. */
  65554. set bloomWeight(value: number);
  65555. get bloomWeight(): number;
  65556. /**
  65557. * The strength of the bloom.
  65558. */
  65559. set bloomThreshold(value: number);
  65560. get bloomThreshold(): number;
  65561. /**
  65562. * The scale of the bloom, lower value will provide better performance.
  65563. */
  65564. set bloomScale(value: number);
  65565. get bloomScale(): number;
  65566. /**
  65567. * Enable or disable the bloom from the pipeline
  65568. */
  65569. set bloomEnabled(enabled: boolean);
  65570. get bloomEnabled(): boolean;
  65571. private _rebuildBloom;
  65572. /**
  65573. * If the depth of field is enabled.
  65574. */
  65575. get depthOfFieldEnabled(): boolean;
  65576. set depthOfFieldEnabled(enabled: boolean);
  65577. /**
  65578. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65579. */
  65580. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65581. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65582. /**
  65583. * If the anti aliasing is enabled.
  65584. */
  65585. set fxaaEnabled(enabled: boolean);
  65586. get fxaaEnabled(): boolean;
  65587. private _samples;
  65588. /**
  65589. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65590. */
  65591. set samples(sampleCount: number);
  65592. get samples(): number;
  65593. /**
  65594. * If image processing is enabled.
  65595. */
  65596. set imageProcessingEnabled(enabled: boolean);
  65597. get imageProcessingEnabled(): boolean;
  65598. /**
  65599. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65600. */
  65601. set glowLayerEnabled(enabled: boolean);
  65602. get glowLayerEnabled(): boolean;
  65603. /**
  65604. * Gets the glow layer (or null if not defined)
  65605. */
  65606. get glowLayer(): Nullable<GlowLayer>;
  65607. /**
  65608. * Enable or disable the chromaticAberration process from the pipeline
  65609. */
  65610. set chromaticAberrationEnabled(enabled: boolean);
  65611. get chromaticAberrationEnabled(): boolean;
  65612. /**
  65613. * Enable or disable the grain process from the pipeline
  65614. */
  65615. set grainEnabled(enabled: boolean);
  65616. get grainEnabled(): boolean;
  65617. /**
  65618. * @constructor
  65619. * @param name - The rendering pipeline name (default: "")
  65620. * @param hdr - If high dynamic range textures should be used (default: true)
  65621. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65622. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65623. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65624. */
  65625. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65626. /**
  65627. * Get the class name
  65628. * @returns "DefaultRenderingPipeline"
  65629. */
  65630. getClassName(): string;
  65631. /**
  65632. * Force the compilation of the entire pipeline.
  65633. */
  65634. prepare(): void;
  65635. private _hasCleared;
  65636. private _prevPostProcess;
  65637. private _prevPrevPostProcess;
  65638. private _setAutoClearAndTextureSharing;
  65639. private _depthOfFieldSceneObserver;
  65640. private _buildPipeline;
  65641. private _disposePostProcesses;
  65642. /**
  65643. * Adds a camera to the pipeline
  65644. * @param camera the camera to be added
  65645. */
  65646. addCamera(camera: Camera): void;
  65647. /**
  65648. * Removes a camera from the pipeline
  65649. * @param camera the camera to remove
  65650. */
  65651. removeCamera(camera: Camera): void;
  65652. /**
  65653. * Dispose of the pipeline and stop all post processes
  65654. */
  65655. dispose(): void;
  65656. /**
  65657. * Serialize the rendering pipeline (Used when exporting)
  65658. * @returns the serialized object
  65659. */
  65660. serialize(): any;
  65661. /**
  65662. * Parse the serialized pipeline
  65663. * @param source Source pipeline.
  65664. * @param scene The scene to load the pipeline to.
  65665. * @param rootUrl The URL of the serialized pipeline.
  65666. * @returns An instantiated pipeline from the serialized object.
  65667. */
  65668. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65669. }
  65670. }
  65671. declare module BABYLON {
  65672. /** @hidden */
  65673. export var lensHighlightsPixelShader: {
  65674. name: string;
  65675. shader: string;
  65676. };
  65677. }
  65678. declare module BABYLON {
  65679. /** @hidden */
  65680. export var depthOfFieldPixelShader: {
  65681. name: string;
  65682. shader: string;
  65683. };
  65684. }
  65685. declare module BABYLON {
  65686. /**
  65687. * BABYLON.JS Chromatic Aberration GLSL Shader
  65688. * Author: Olivier Guyot
  65689. * Separates very slightly R, G and B colors on the edges of the screen
  65690. * Inspired by Francois Tarlier & Martins Upitis
  65691. */
  65692. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65693. /**
  65694. * @ignore
  65695. * The chromatic aberration PostProcess id in the pipeline
  65696. */
  65697. LensChromaticAberrationEffect: string;
  65698. /**
  65699. * @ignore
  65700. * The highlights enhancing PostProcess id in the pipeline
  65701. */
  65702. HighlightsEnhancingEffect: string;
  65703. /**
  65704. * @ignore
  65705. * The depth-of-field PostProcess id in the pipeline
  65706. */
  65707. LensDepthOfFieldEffect: string;
  65708. private _scene;
  65709. private _depthTexture;
  65710. private _grainTexture;
  65711. private _chromaticAberrationPostProcess;
  65712. private _highlightsPostProcess;
  65713. private _depthOfFieldPostProcess;
  65714. private _edgeBlur;
  65715. private _grainAmount;
  65716. private _chromaticAberration;
  65717. private _distortion;
  65718. private _highlightsGain;
  65719. private _highlightsThreshold;
  65720. private _dofDistance;
  65721. private _dofAperture;
  65722. private _dofDarken;
  65723. private _dofPentagon;
  65724. private _blurNoise;
  65725. /**
  65726. * @constructor
  65727. *
  65728. * Effect parameters are as follow:
  65729. * {
  65730. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65731. * edge_blur: number; // from 0 to x (1 for realism)
  65732. * distortion: number; // from 0 to x (1 for realism)
  65733. * grain_amount: number; // from 0 to 1
  65734. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65735. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65736. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65737. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65738. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65739. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65740. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65741. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65742. * }
  65743. * Note: if an effect parameter is unset, effect is disabled
  65744. *
  65745. * @param name The rendering pipeline name
  65746. * @param parameters - An object containing all parameters (see above)
  65747. * @param scene The scene linked to this pipeline
  65748. * @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)
  65749. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65750. */
  65751. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65752. /**
  65753. * Get the class name
  65754. * @returns "LensRenderingPipeline"
  65755. */
  65756. getClassName(): string;
  65757. /**
  65758. * Gets associated scene
  65759. */
  65760. get scene(): Scene;
  65761. /**
  65762. * Gets or sets the edge blur
  65763. */
  65764. get edgeBlur(): number;
  65765. set edgeBlur(value: number);
  65766. /**
  65767. * Gets or sets the grain amount
  65768. */
  65769. get grainAmount(): number;
  65770. set grainAmount(value: number);
  65771. /**
  65772. * Gets or sets the chromatic aberration amount
  65773. */
  65774. get chromaticAberration(): number;
  65775. set chromaticAberration(value: number);
  65776. /**
  65777. * Gets or sets the depth of field aperture
  65778. */
  65779. get dofAperture(): number;
  65780. set dofAperture(value: number);
  65781. /**
  65782. * Gets or sets the edge distortion
  65783. */
  65784. get edgeDistortion(): number;
  65785. set edgeDistortion(value: number);
  65786. /**
  65787. * Gets or sets the depth of field distortion
  65788. */
  65789. get dofDistortion(): number;
  65790. set dofDistortion(value: number);
  65791. /**
  65792. * Gets or sets the darken out of focus amount
  65793. */
  65794. get darkenOutOfFocus(): number;
  65795. set darkenOutOfFocus(value: number);
  65796. /**
  65797. * Gets or sets a boolean indicating if blur noise is enabled
  65798. */
  65799. get blurNoise(): boolean;
  65800. set blurNoise(value: boolean);
  65801. /**
  65802. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65803. */
  65804. get pentagonBokeh(): boolean;
  65805. set pentagonBokeh(value: boolean);
  65806. /**
  65807. * Gets or sets the highlight grain amount
  65808. */
  65809. get highlightsGain(): number;
  65810. set highlightsGain(value: number);
  65811. /**
  65812. * Gets or sets the highlight threshold
  65813. */
  65814. get highlightsThreshold(): number;
  65815. set highlightsThreshold(value: number);
  65816. /**
  65817. * Sets the amount of blur at the edges
  65818. * @param amount blur amount
  65819. */
  65820. setEdgeBlur(amount: number): void;
  65821. /**
  65822. * Sets edge blur to 0
  65823. */
  65824. disableEdgeBlur(): void;
  65825. /**
  65826. * Sets the amout of grain
  65827. * @param amount Amount of grain
  65828. */
  65829. setGrainAmount(amount: number): void;
  65830. /**
  65831. * Set grain amount to 0
  65832. */
  65833. disableGrain(): void;
  65834. /**
  65835. * Sets the chromatic aberration amount
  65836. * @param amount amount of chromatic aberration
  65837. */
  65838. setChromaticAberration(amount: number): void;
  65839. /**
  65840. * Sets chromatic aberration amount to 0
  65841. */
  65842. disableChromaticAberration(): void;
  65843. /**
  65844. * Sets the EdgeDistortion amount
  65845. * @param amount amount of EdgeDistortion
  65846. */
  65847. setEdgeDistortion(amount: number): void;
  65848. /**
  65849. * Sets edge distortion to 0
  65850. */
  65851. disableEdgeDistortion(): void;
  65852. /**
  65853. * Sets the FocusDistance amount
  65854. * @param amount amount of FocusDistance
  65855. */
  65856. setFocusDistance(amount: number): void;
  65857. /**
  65858. * Disables depth of field
  65859. */
  65860. disableDepthOfField(): void;
  65861. /**
  65862. * Sets the Aperture amount
  65863. * @param amount amount of Aperture
  65864. */
  65865. setAperture(amount: number): void;
  65866. /**
  65867. * Sets the DarkenOutOfFocus amount
  65868. * @param amount amount of DarkenOutOfFocus
  65869. */
  65870. setDarkenOutOfFocus(amount: number): void;
  65871. private _pentagonBokehIsEnabled;
  65872. /**
  65873. * Creates a pentagon bokeh effect
  65874. */
  65875. enablePentagonBokeh(): void;
  65876. /**
  65877. * Disables the pentagon bokeh effect
  65878. */
  65879. disablePentagonBokeh(): void;
  65880. /**
  65881. * Enables noise blur
  65882. */
  65883. enableNoiseBlur(): void;
  65884. /**
  65885. * Disables noise blur
  65886. */
  65887. disableNoiseBlur(): void;
  65888. /**
  65889. * Sets the HighlightsGain amount
  65890. * @param amount amount of HighlightsGain
  65891. */
  65892. setHighlightsGain(amount: number): void;
  65893. /**
  65894. * Sets the HighlightsThreshold amount
  65895. * @param amount amount of HighlightsThreshold
  65896. */
  65897. setHighlightsThreshold(amount: number): void;
  65898. /**
  65899. * Disables highlights
  65900. */
  65901. disableHighlights(): void;
  65902. /**
  65903. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65904. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65905. */
  65906. dispose(disableDepthRender?: boolean): void;
  65907. private _createChromaticAberrationPostProcess;
  65908. private _createHighlightsPostProcess;
  65909. private _createDepthOfFieldPostProcess;
  65910. private _createGrainTexture;
  65911. }
  65912. }
  65913. declare module BABYLON {
  65914. /** @hidden */
  65915. export var ssao2PixelShader: {
  65916. name: string;
  65917. shader: string;
  65918. };
  65919. }
  65920. declare module BABYLON {
  65921. /** @hidden */
  65922. export var ssaoCombinePixelShader: {
  65923. name: string;
  65924. shader: string;
  65925. };
  65926. }
  65927. declare module BABYLON {
  65928. /**
  65929. * Render pipeline to produce ssao effect
  65930. */
  65931. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65932. /**
  65933. * @ignore
  65934. * The PassPostProcess id in the pipeline that contains the original scene color
  65935. */
  65936. SSAOOriginalSceneColorEffect: string;
  65937. /**
  65938. * @ignore
  65939. * The SSAO PostProcess id in the pipeline
  65940. */
  65941. SSAORenderEffect: string;
  65942. /**
  65943. * @ignore
  65944. * The horizontal blur PostProcess id in the pipeline
  65945. */
  65946. SSAOBlurHRenderEffect: string;
  65947. /**
  65948. * @ignore
  65949. * The vertical blur PostProcess id in the pipeline
  65950. */
  65951. SSAOBlurVRenderEffect: string;
  65952. /**
  65953. * @ignore
  65954. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65955. */
  65956. SSAOCombineRenderEffect: string;
  65957. /**
  65958. * The output strength of the SSAO post-process. Default value is 1.0.
  65959. */
  65960. totalStrength: number;
  65961. /**
  65962. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65963. */
  65964. maxZ: number;
  65965. /**
  65966. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65967. */
  65968. minZAspect: number;
  65969. private _samples;
  65970. /**
  65971. * Number of samples used for the SSAO calculations. Default value is 8
  65972. */
  65973. set samples(n: number);
  65974. get samples(): number;
  65975. private _textureSamples;
  65976. /**
  65977. * Number of samples to use for antialiasing
  65978. */
  65979. set textureSamples(n: number);
  65980. get textureSamples(): number;
  65981. /**
  65982. * Ratio object used for SSAO ratio and blur ratio
  65983. */
  65984. private _ratio;
  65985. /**
  65986. * Dynamically generated sphere sampler.
  65987. */
  65988. private _sampleSphere;
  65989. /**
  65990. * Blur filter offsets
  65991. */
  65992. private _samplerOffsets;
  65993. private _expensiveBlur;
  65994. /**
  65995. * If bilateral blur should be used
  65996. */
  65997. set expensiveBlur(b: boolean);
  65998. get expensiveBlur(): boolean;
  65999. /**
  66000. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66001. */
  66002. radius: number;
  66003. /**
  66004. * The base color of the SSAO post-process
  66005. * The final result is "base + ssao" between [0, 1]
  66006. */
  66007. base: number;
  66008. /**
  66009. * Support test.
  66010. */
  66011. static get IsSupported(): boolean;
  66012. private _scene;
  66013. private _depthTexture;
  66014. private _normalTexture;
  66015. private _randomTexture;
  66016. private _originalColorPostProcess;
  66017. private _ssaoPostProcess;
  66018. private _blurHPostProcess;
  66019. private _blurVPostProcess;
  66020. private _ssaoCombinePostProcess;
  66021. /**
  66022. * Gets active scene
  66023. */
  66024. get scene(): Scene;
  66025. /**
  66026. * @constructor
  66027. * @param name The rendering pipeline name
  66028. * @param scene The scene linked to this pipeline
  66029. * @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 }
  66030. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66031. */
  66032. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66033. /**
  66034. * Get the class name
  66035. * @returns "SSAO2RenderingPipeline"
  66036. */
  66037. getClassName(): string;
  66038. /**
  66039. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66040. */
  66041. dispose(disableGeometryBufferRenderer?: boolean): void;
  66042. private _createBlurPostProcess;
  66043. /** @hidden */
  66044. _rebuild(): void;
  66045. private _bits;
  66046. private _radicalInverse_VdC;
  66047. private _hammersley;
  66048. private _hemisphereSample_uniform;
  66049. private _generateHemisphere;
  66050. private _createSSAOPostProcess;
  66051. private _createSSAOCombinePostProcess;
  66052. private _createRandomTexture;
  66053. /**
  66054. * Serialize the rendering pipeline (Used when exporting)
  66055. * @returns the serialized object
  66056. */
  66057. serialize(): any;
  66058. /**
  66059. * Parse the serialized pipeline
  66060. * @param source Source pipeline.
  66061. * @param scene The scene to load the pipeline to.
  66062. * @param rootUrl The URL of the serialized pipeline.
  66063. * @returns An instantiated pipeline from the serialized object.
  66064. */
  66065. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66066. }
  66067. }
  66068. declare module BABYLON {
  66069. /** @hidden */
  66070. export var ssaoPixelShader: {
  66071. name: string;
  66072. shader: string;
  66073. };
  66074. }
  66075. declare module BABYLON {
  66076. /**
  66077. * Render pipeline to produce ssao effect
  66078. */
  66079. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66080. /**
  66081. * @ignore
  66082. * The PassPostProcess id in the pipeline that contains the original scene color
  66083. */
  66084. SSAOOriginalSceneColorEffect: string;
  66085. /**
  66086. * @ignore
  66087. * The SSAO PostProcess id in the pipeline
  66088. */
  66089. SSAORenderEffect: string;
  66090. /**
  66091. * @ignore
  66092. * The horizontal blur PostProcess id in the pipeline
  66093. */
  66094. SSAOBlurHRenderEffect: string;
  66095. /**
  66096. * @ignore
  66097. * The vertical blur PostProcess id in the pipeline
  66098. */
  66099. SSAOBlurVRenderEffect: string;
  66100. /**
  66101. * @ignore
  66102. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66103. */
  66104. SSAOCombineRenderEffect: string;
  66105. /**
  66106. * The output strength of the SSAO post-process. Default value is 1.0.
  66107. */
  66108. totalStrength: number;
  66109. /**
  66110. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66111. */
  66112. radius: number;
  66113. /**
  66114. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66115. * Must not be equal to fallOff and superior to fallOff.
  66116. * Default value is 0.0075
  66117. */
  66118. area: number;
  66119. /**
  66120. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66121. * Must not be equal to area and inferior to area.
  66122. * Default value is 0.000001
  66123. */
  66124. fallOff: number;
  66125. /**
  66126. * The base color of the SSAO post-process
  66127. * The final result is "base + ssao" between [0, 1]
  66128. */
  66129. base: number;
  66130. private _scene;
  66131. private _depthTexture;
  66132. private _randomTexture;
  66133. private _originalColorPostProcess;
  66134. private _ssaoPostProcess;
  66135. private _blurHPostProcess;
  66136. private _blurVPostProcess;
  66137. private _ssaoCombinePostProcess;
  66138. private _firstUpdate;
  66139. /**
  66140. * Gets active scene
  66141. */
  66142. get scene(): Scene;
  66143. /**
  66144. * @constructor
  66145. * @param name - The rendering pipeline name
  66146. * @param scene - The scene linked to this pipeline
  66147. * @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 }
  66148. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66149. */
  66150. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66151. /**
  66152. * Get the class name
  66153. * @returns "SSAORenderingPipeline"
  66154. */
  66155. getClassName(): string;
  66156. /**
  66157. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66158. */
  66159. dispose(disableDepthRender?: boolean): void;
  66160. private _createBlurPostProcess;
  66161. /** @hidden */
  66162. _rebuild(): void;
  66163. private _createSSAOPostProcess;
  66164. private _createSSAOCombinePostProcess;
  66165. private _createRandomTexture;
  66166. }
  66167. }
  66168. declare module BABYLON {
  66169. /** @hidden */
  66170. export var screenSpaceReflectionPixelShader: {
  66171. name: string;
  66172. shader: string;
  66173. };
  66174. }
  66175. declare module BABYLON {
  66176. /**
  66177. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66178. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66179. */
  66180. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66181. /**
  66182. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66183. */
  66184. threshold: number;
  66185. /**
  66186. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66187. */
  66188. strength: number;
  66189. /**
  66190. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66191. */
  66192. reflectionSpecularFalloffExponent: number;
  66193. /**
  66194. * 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]
  66195. */
  66196. step: number;
  66197. /**
  66198. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66199. */
  66200. roughnessFactor: number;
  66201. private _geometryBufferRenderer;
  66202. private _enableSmoothReflections;
  66203. private _reflectionSamples;
  66204. private _smoothSteps;
  66205. /**
  66206. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66207. * @param name The name of the effect.
  66208. * @param scene The scene containing the objects to calculate reflections.
  66209. * @param options The required width/height ratio to downsize to before computing the render pass.
  66210. * @param camera The camera to apply the render pass to.
  66211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66212. * @param engine The engine which the post process will be applied. (default: current engine)
  66213. * @param reusable If the post process can be reused on the same frame. (default: false)
  66214. * @param textureType Type of textures used when performing the post process. (default: 0)
  66215. * @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)
  66216. */
  66217. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66218. /**
  66219. * Gets wether or not smoothing reflections is enabled.
  66220. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66221. */
  66222. get enableSmoothReflections(): boolean;
  66223. /**
  66224. * Sets wether or not smoothing reflections is enabled.
  66225. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66226. */
  66227. set enableSmoothReflections(enabled: boolean);
  66228. /**
  66229. * Gets the number of samples taken while computing reflections. More samples count is high,
  66230. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66231. */
  66232. get reflectionSamples(): number;
  66233. /**
  66234. * Sets the number of samples taken while computing reflections. More samples count is high,
  66235. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66236. */
  66237. set reflectionSamples(samples: number);
  66238. /**
  66239. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66240. * more the post-process will require GPU power and can generate a drop in FPS.
  66241. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66242. */
  66243. get smoothSteps(): number;
  66244. set smoothSteps(steps: number);
  66245. private _updateEffectDefines;
  66246. }
  66247. }
  66248. declare module BABYLON {
  66249. /** @hidden */
  66250. export var standardPixelShader: {
  66251. name: string;
  66252. shader: string;
  66253. };
  66254. }
  66255. declare module BABYLON {
  66256. /**
  66257. * Standard rendering pipeline
  66258. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66259. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66260. */
  66261. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66262. /**
  66263. * Public members
  66264. */
  66265. /**
  66266. * Post-process which contains the original scene color before the pipeline applies all the effects
  66267. */
  66268. originalPostProcess: Nullable<PostProcess>;
  66269. /**
  66270. * Post-process used to down scale an image x4
  66271. */
  66272. downSampleX4PostProcess: Nullable<PostProcess>;
  66273. /**
  66274. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66275. */
  66276. brightPassPostProcess: Nullable<PostProcess>;
  66277. /**
  66278. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66279. */
  66280. blurHPostProcesses: PostProcess[];
  66281. /**
  66282. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66283. */
  66284. blurVPostProcesses: PostProcess[];
  66285. /**
  66286. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66287. */
  66288. textureAdderPostProcess: Nullable<PostProcess>;
  66289. /**
  66290. * Post-process used to create volumetric lighting effect
  66291. */
  66292. volumetricLightPostProcess: Nullable<PostProcess>;
  66293. /**
  66294. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66295. */
  66296. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66297. /**
  66298. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66299. */
  66300. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66301. /**
  66302. * Post-process used to merge the volumetric light effect and the real scene color
  66303. */
  66304. volumetricLightMergePostProces: Nullable<PostProcess>;
  66305. /**
  66306. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66307. */
  66308. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66309. /**
  66310. * Base post-process used to calculate the average luminance of the final image for HDR
  66311. */
  66312. luminancePostProcess: Nullable<PostProcess>;
  66313. /**
  66314. * Post-processes used to create down sample post-processes in order to get
  66315. * the average luminance of the final image for HDR
  66316. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66317. */
  66318. luminanceDownSamplePostProcesses: PostProcess[];
  66319. /**
  66320. * Post-process used to create a HDR effect (light adaptation)
  66321. */
  66322. hdrPostProcess: Nullable<PostProcess>;
  66323. /**
  66324. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66325. */
  66326. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66327. /**
  66328. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66329. */
  66330. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66331. /**
  66332. * Post-process used to merge the final HDR post-process and the real scene color
  66333. */
  66334. hdrFinalPostProcess: Nullable<PostProcess>;
  66335. /**
  66336. * Post-process used to create a lens flare effect
  66337. */
  66338. lensFlarePostProcess: Nullable<PostProcess>;
  66339. /**
  66340. * Post-process that merges the result of the lens flare post-process and the real scene color
  66341. */
  66342. lensFlareComposePostProcess: Nullable<PostProcess>;
  66343. /**
  66344. * Post-process used to create a motion blur effect
  66345. */
  66346. motionBlurPostProcess: Nullable<PostProcess>;
  66347. /**
  66348. * Post-process used to create a depth of field effect
  66349. */
  66350. depthOfFieldPostProcess: Nullable<PostProcess>;
  66351. /**
  66352. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66353. */
  66354. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66355. /**
  66356. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66357. */
  66358. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66359. /**
  66360. * Represents the brightness threshold in order to configure the illuminated surfaces
  66361. */
  66362. brightThreshold: number;
  66363. /**
  66364. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66365. */
  66366. blurWidth: number;
  66367. /**
  66368. * Sets if the blur for highlighted surfaces must be only horizontal
  66369. */
  66370. horizontalBlur: boolean;
  66371. /**
  66372. * Gets the overall exposure used by the pipeline
  66373. */
  66374. get exposure(): number;
  66375. /**
  66376. * Sets the overall exposure used by the pipeline
  66377. */
  66378. set exposure(value: number);
  66379. /**
  66380. * Texture used typically to simulate "dirty" on camera lens
  66381. */
  66382. lensTexture: Nullable<Texture>;
  66383. /**
  66384. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66385. */
  66386. volumetricLightCoefficient: number;
  66387. /**
  66388. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66389. */
  66390. volumetricLightPower: number;
  66391. /**
  66392. * Used the set the blur intensity to smooth the volumetric lights
  66393. */
  66394. volumetricLightBlurScale: number;
  66395. /**
  66396. * Light (spot or directional) used to generate the volumetric lights rays
  66397. * The source light must have a shadow generate so the pipeline can get its
  66398. * depth map
  66399. */
  66400. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66401. /**
  66402. * For eye adaptation, represents the minimum luminance the eye can see
  66403. */
  66404. hdrMinimumLuminance: number;
  66405. /**
  66406. * For eye adaptation, represents the decrease luminance speed
  66407. */
  66408. hdrDecreaseRate: number;
  66409. /**
  66410. * For eye adaptation, represents the increase luminance speed
  66411. */
  66412. hdrIncreaseRate: number;
  66413. /**
  66414. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66415. */
  66416. get hdrAutoExposure(): boolean;
  66417. /**
  66418. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66419. */
  66420. set hdrAutoExposure(value: boolean);
  66421. /**
  66422. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66423. */
  66424. lensColorTexture: Nullable<Texture>;
  66425. /**
  66426. * The overall strengh for the lens flare effect
  66427. */
  66428. lensFlareStrength: number;
  66429. /**
  66430. * Dispersion coefficient for lens flare ghosts
  66431. */
  66432. lensFlareGhostDispersal: number;
  66433. /**
  66434. * Main lens flare halo width
  66435. */
  66436. lensFlareHaloWidth: number;
  66437. /**
  66438. * Based on the lens distortion effect, defines how much the lens flare result
  66439. * is distorted
  66440. */
  66441. lensFlareDistortionStrength: number;
  66442. /**
  66443. * Configures the blur intensity used for for lens flare (halo)
  66444. */
  66445. lensFlareBlurWidth: number;
  66446. /**
  66447. * Lens star texture must be used to simulate rays on the flares and is available
  66448. * in the documentation
  66449. */
  66450. lensStarTexture: Nullable<Texture>;
  66451. /**
  66452. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66453. * flare effect by taking account of the dirt texture
  66454. */
  66455. lensFlareDirtTexture: Nullable<Texture>;
  66456. /**
  66457. * Represents the focal length for the depth of field effect
  66458. */
  66459. depthOfFieldDistance: number;
  66460. /**
  66461. * Represents the blur intensity for the blurred part of the depth of field effect
  66462. */
  66463. depthOfFieldBlurWidth: number;
  66464. /**
  66465. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66466. */
  66467. get motionStrength(): number;
  66468. /**
  66469. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66470. */
  66471. set motionStrength(strength: number);
  66472. /**
  66473. * Gets wether or not the motion blur post-process is object based or screen based.
  66474. */
  66475. get objectBasedMotionBlur(): boolean;
  66476. /**
  66477. * Sets wether or not the motion blur post-process should be object based or screen based
  66478. */
  66479. set objectBasedMotionBlur(value: boolean);
  66480. /**
  66481. * List of animations for the pipeline (IAnimatable implementation)
  66482. */
  66483. animations: Animation[];
  66484. /**
  66485. * Private members
  66486. */
  66487. private _scene;
  66488. private _currentDepthOfFieldSource;
  66489. private _basePostProcess;
  66490. private _fixedExposure;
  66491. private _currentExposure;
  66492. private _hdrAutoExposure;
  66493. private _hdrCurrentLuminance;
  66494. private _motionStrength;
  66495. private _isObjectBasedMotionBlur;
  66496. private _floatTextureType;
  66497. private _camerasToBeAttached;
  66498. private _ratio;
  66499. private _bloomEnabled;
  66500. private _depthOfFieldEnabled;
  66501. private _vlsEnabled;
  66502. private _lensFlareEnabled;
  66503. private _hdrEnabled;
  66504. private _motionBlurEnabled;
  66505. private _fxaaEnabled;
  66506. private _screenSpaceReflectionsEnabled;
  66507. private _motionBlurSamples;
  66508. private _volumetricLightStepsCount;
  66509. private _samples;
  66510. /**
  66511. * @ignore
  66512. * Specifies if the bloom pipeline is enabled
  66513. */
  66514. get BloomEnabled(): boolean;
  66515. set BloomEnabled(enabled: boolean);
  66516. /**
  66517. * @ignore
  66518. * Specifies if the depth of field pipeline is enabed
  66519. */
  66520. get DepthOfFieldEnabled(): boolean;
  66521. set DepthOfFieldEnabled(enabled: boolean);
  66522. /**
  66523. * @ignore
  66524. * Specifies if the lens flare pipeline is enabed
  66525. */
  66526. get LensFlareEnabled(): boolean;
  66527. set LensFlareEnabled(enabled: boolean);
  66528. /**
  66529. * @ignore
  66530. * Specifies if the HDR pipeline is enabled
  66531. */
  66532. get HDREnabled(): boolean;
  66533. set HDREnabled(enabled: boolean);
  66534. /**
  66535. * @ignore
  66536. * Specifies if the volumetric lights scattering effect is enabled
  66537. */
  66538. get VLSEnabled(): boolean;
  66539. set VLSEnabled(enabled: boolean);
  66540. /**
  66541. * @ignore
  66542. * Specifies if the motion blur effect is enabled
  66543. */
  66544. get MotionBlurEnabled(): boolean;
  66545. set MotionBlurEnabled(enabled: boolean);
  66546. /**
  66547. * Specifies if anti-aliasing is enabled
  66548. */
  66549. get fxaaEnabled(): boolean;
  66550. set fxaaEnabled(enabled: boolean);
  66551. /**
  66552. * Specifies if screen space reflections are enabled.
  66553. */
  66554. get screenSpaceReflectionsEnabled(): boolean;
  66555. set screenSpaceReflectionsEnabled(enabled: boolean);
  66556. /**
  66557. * Specifies the number of steps used to calculate the volumetric lights
  66558. * Typically in interval [50, 200]
  66559. */
  66560. get volumetricLightStepsCount(): number;
  66561. set volumetricLightStepsCount(count: number);
  66562. /**
  66563. * Specifies the number of samples used for the motion blur effect
  66564. * Typically in interval [16, 64]
  66565. */
  66566. get motionBlurSamples(): number;
  66567. set motionBlurSamples(samples: number);
  66568. /**
  66569. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66570. */
  66571. get samples(): number;
  66572. set samples(sampleCount: number);
  66573. /**
  66574. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66575. * @constructor
  66576. * @param name The rendering pipeline name
  66577. * @param scene The scene linked to this pipeline
  66578. * @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)
  66579. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66580. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66581. */
  66582. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66583. private _buildPipeline;
  66584. private _createDownSampleX4PostProcess;
  66585. private _createBrightPassPostProcess;
  66586. private _createBlurPostProcesses;
  66587. private _createTextureAdderPostProcess;
  66588. private _createVolumetricLightPostProcess;
  66589. private _createLuminancePostProcesses;
  66590. private _createHdrPostProcess;
  66591. private _createLensFlarePostProcess;
  66592. private _createDepthOfFieldPostProcess;
  66593. private _createMotionBlurPostProcess;
  66594. private _getDepthTexture;
  66595. private _disposePostProcesses;
  66596. /**
  66597. * Dispose of the pipeline and stop all post processes
  66598. */
  66599. dispose(): void;
  66600. /**
  66601. * Serialize the rendering pipeline (Used when exporting)
  66602. * @returns the serialized object
  66603. */
  66604. serialize(): any;
  66605. /**
  66606. * Parse the serialized pipeline
  66607. * @param source Source pipeline.
  66608. * @param scene The scene to load the pipeline to.
  66609. * @param rootUrl The URL of the serialized pipeline.
  66610. * @returns An instantiated pipeline from the serialized object.
  66611. */
  66612. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66613. /**
  66614. * Luminance steps
  66615. */
  66616. static LuminanceSteps: number;
  66617. }
  66618. }
  66619. declare module BABYLON {
  66620. /** @hidden */
  66621. export var tonemapPixelShader: {
  66622. name: string;
  66623. shader: string;
  66624. };
  66625. }
  66626. declare module BABYLON {
  66627. /** Defines operator used for tonemapping */
  66628. export enum TonemappingOperator {
  66629. /** Hable */
  66630. Hable = 0,
  66631. /** Reinhard */
  66632. Reinhard = 1,
  66633. /** HejiDawson */
  66634. HejiDawson = 2,
  66635. /** Photographic */
  66636. Photographic = 3
  66637. }
  66638. /**
  66639. * Defines a post process to apply tone mapping
  66640. */
  66641. export class TonemapPostProcess extends PostProcess {
  66642. private _operator;
  66643. /** Defines the required exposure adjustement */
  66644. exposureAdjustment: number;
  66645. /**
  66646. * Creates a new TonemapPostProcess
  66647. * @param name defines the name of the postprocess
  66648. * @param _operator defines the operator to use
  66649. * @param exposureAdjustment defines the required exposure adjustement
  66650. * @param camera defines the camera to use (can be null)
  66651. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66652. * @param engine defines the hosting engine (can be ignore if camera is set)
  66653. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66654. */
  66655. constructor(name: string, _operator: TonemappingOperator,
  66656. /** Defines the required exposure adjustement */
  66657. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66658. }
  66659. }
  66660. declare module BABYLON {
  66661. /** @hidden */
  66662. export var volumetricLightScatteringPixelShader: {
  66663. name: string;
  66664. shader: string;
  66665. };
  66666. }
  66667. declare module BABYLON {
  66668. /** @hidden */
  66669. export var volumetricLightScatteringPassVertexShader: {
  66670. name: string;
  66671. shader: string;
  66672. };
  66673. }
  66674. declare module BABYLON {
  66675. /** @hidden */
  66676. export var volumetricLightScatteringPassPixelShader: {
  66677. name: string;
  66678. shader: string;
  66679. };
  66680. }
  66681. declare module BABYLON {
  66682. /**
  66683. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66684. */
  66685. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66686. private _volumetricLightScatteringPass;
  66687. private _volumetricLightScatteringRTT;
  66688. private _viewPort;
  66689. private _screenCoordinates;
  66690. private _cachedDefines;
  66691. /**
  66692. * If not undefined, the mesh position is computed from the attached node position
  66693. */
  66694. attachedNode: {
  66695. position: Vector3;
  66696. };
  66697. /**
  66698. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66699. */
  66700. customMeshPosition: Vector3;
  66701. /**
  66702. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66703. */
  66704. useCustomMeshPosition: boolean;
  66705. /**
  66706. * If the post-process should inverse the light scattering direction
  66707. */
  66708. invert: boolean;
  66709. /**
  66710. * The internal mesh used by the post-process
  66711. */
  66712. mesh: Mesh;
  66713. /**
  66714. * @hidden
  66715. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66716. */
  66717. get useDiffuseColor(): boolean;
  66718. set useDiffuseColor(useDiffuseColor: boolean);
  66719. /**
  66720. * Array containing the excluded meshes not rendered in the internal pass
  66721. */
  66722. excludedMeshes: AbstractMesh[];
  66723. /**
  66724. * Controls the overall intensity of the post-process
  66725. */
  66726. exposure: number;
  66727. /**
  66728. * Dissipates each sample's contribution in range [0, 1]
  66729. */
  66730. decay: number;
  66731. /**
  66732. * Controls the overall intensity of each sample
  66733. */
  66734. weight: number;
  66735. /**
  66736. * Controls the density of each sample
  66737. */
  66738. density: number;
  66739. /**
  66740. * @constructor
  66741. * @param name The post-process name
  66742. * @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)
  66743. * @param camera The camera that the post-process will be attached to
  66744. * @param mesh The mesh used to create the light scattering
  66745. * @param samples The post-process quality, default 100
  66746. * @param samplingModeThe post-process filtering mode
  66747. * @param engine The babylon engine
  66748. * @param reusable If the post-process is reusable
  66749. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66750. */
  66751. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66752. /**
  66753. * Returns the string "VolumetricLightScatteringPostProcess"
  66754. * @returns "VolumetricLightScatteringPostProcess"
  66755. */
  66756. getClassName(): string;
  66757. private _isReady;
  66758. /**
  66759. * Sets the new light position for light scattering effect
  66760. * @param position The new custom light position
  66761. */
  66762. setCustomMeshPosition(position: Vector3): void;
  66763. /**
  66764. * Returns the light position for light scattering effect
  66765. * @return Vector3 The custom light position
  66766. */
  66767. getCustomMeshPosition(): Vector3;
  66768. /**
  66769. * Disposes the internal assets and detaches the post-process from the camera
  66770. */
  66771. dispose(camera: Camera): void;
  66772. /**
  66773. * Returns the render target texture used by the post-process
  66774. * @return the render target texture used by the post-process
  66775. */
  66776. getPass(): RenderTargetTexture;
  66777. private _meshExcluded;
  66778. private _createPass;
  66779. private _updateMeshScreenCoordinates;
  66780. /**
  66781. * Creates a default mesh for the Volumeric Light Scattering post-process
  66782. * @param name The mesh name
  66783. * @param scene The scene where to create the mesh
  66784. * @return the default mesh
  66785. */
  66786. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66787. }
  66788. }
  66789. declare module BABYLON {
  66790. interface Scene {
  66791. /** @hidden (Backing field) */
  66792. _boundingBoxRenderer: BoundingBoxRenderer;
  66793. /** @hidden (Backing field) */
  66794. _forceShowBoundingBoxes: boolean;
  66795. /**
  66796. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66797. */
  66798. forceShowBoundingBoxes: boolean;
  66799. /**
  66800. * Gets the bounding box renderer associated with the scene
  66801. * @returns a BoundingBoxRenderer
  66802. */
  66803. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66804. }
  66805. interface AbstractMesh {
  66806. /** @hidden (Backing field) */
  66807. _showBoundingBox: boolean;
  66808. /**
  66809. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66810. */
  66811. showBoundingBox: boolean;
  66812. }
  66813. /**
  66814. * Component responsible of rendering the bounding box of the meshes in a scene.
  66815. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66816. */
  66817. export class BoundingBoxRenderer implements ISceneComponent {
  66818. /**
  66819. * The component name helpfull to identify the component in the list of scene components.
  66820. */
  66821. readonly name: string;
  66822. /**
  66823. * The scene the component belongs to.
  66824. */
  66825. scene: Scene;
  66826. /**
  66827. * Color of the bounding box lines placed in front of an object
  66828. */
  66829. frontColor: Color3;
  66830. /**
  66831. * Color of the bounding box lines placed behind an object
  66832. */
  66833. backColor: Color3;
  66834. /**
  66835. * Defines if the renderer should show the back lines or not
  66836. */
  66837. showBackLines: boolean;
  66838. /**
  66839. * @hidden
  66840. */
  66841. renderList: SmartArray<BoundingBox>;
  66842. private _colorShader;
  66843. private _vertexBuffers;
  66844. private _indexBuffer;
  66845. private _fillIndexBuffer;
  66846. private _fillIndexData;
  66847. /**
  66848. * Instantiates a new bounding box renderer in a scene.
  66849. * @param scene the scene the renderer renders in
  66850. */
  66851. constructor(scene: Scene);
  66852. /**
  66853. * Registers the component in a given scene
  66854. */
  66855. register(): void;
  66856. private _evaluateSubMesh;
  66857. private _activeMesh;
  66858. private _prepareRessources;
  66859. private _createIndexBuffer;
  66860. /**
  66861. * Rebuilds the elements related to this component in case of
  66862. * context lost for instance.
  66863. */
  66864. rebuild(): void;
  66865. /**
  66866. * @hidden
  66867. */
  66868. reset(): void;
  66869. /**
  66870. * Render the bounding boxes of a specific rendering group
  66871. * @param renderingGroupId defines the rendering group to render
  66872. */
  66873. render(renderingGroupId: number): void;
  66874. /**
  66875. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66876. * @param mesh Define the mesh to render the occlusion bounding box for
  66877. */
  66878. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66879. /**
  66880. * Dispose and release the resources attached to this renderer.
  66881. */
  66882. dispose(): void;
  66883. }
  66884. }
  66885. declare module BABYLON {
  66886. interface Scene {
  66887. /** @hidden (Backing field) */
  66888. _depthRenderer: {
  66889. [id: string]: DepthRenderer;
  66890. };
  66891. /**
  66892. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66893. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66894. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66895. * @returns the created depth renderer
  66896. */
  66897. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66898. /**
  66899. * Disables a depth renderer for a given camera
  66900. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66901. */
  66902. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66903. }
  66904. /**
  66905. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66906. * in several rendering techniques.
  66907. */
  66908. export class DepthRendererSceneComponent implements ISceneComponent {
  66909. /**
  66910. * The component name helpfull to identify the component in the list of scene components.
  66911. */
  66912. readonly name: string;
  66913. /**
  66914. * The scene the component belongs to.
  66915. */
  66916. scene: Scene;
  66917. /**
  66918. * Creates a new instance of the component for the given scene
  66919. * @param scene Defines the scene to register the component in
  66920. */
  66921. constructor(scene: Scene);
  66922. /**
  66923. * Registers the component in a given scene
  66924. */
  66925. register(): void;
  66926. /**
  66927. * Rebuilds the elements related to this component in case of
  66928. * context lost for instance.
  66929. */
  66930. rebuild(): void;
  66931. /**
  66932. * Disposes the component and the associated ressources
  66933. */
  66934. dispose(): void;
  66935. private _gatherRenderTargets;
  66936. private _gatherActiveCameraRenderTargets;
  66937. }
  66938. }
  66939. declare module BABYLON {
  66940. /** @hidden */
  66941. export var outlinePixelShader: {
  66942. name: string;
  66943. shader: string;
  66944. };
  66945. }
  66946. declare module BABYLON {
  66947. /** @hidden */
  66948. export var outlineVertexShader: {
  66949. name: string;
  66950. shader: string;
  66951. };
  66952. }
  66953. declare module BABYLON {
  66954. interface Scene {
  66955. /** @hidden */
  66956. _outlineRenderer: OutlineRenderer;
  66957. /**
  66958. * Gets the outline renderer associated with the scene
  66959. * @returns a OutlineRenderer
  66960. */
  66961. getOutlineRenderer(): OutlineRenderer;
  66962. }
  66963. interface AbstractMesh {
  66964. /** @hidden (Backing field) */
  66965. _renderOutline: boolean;
  66966. /**
  66967. * Gets or sets a boolean indicating if the outline must be rendered as well
  66968. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66969. */
  66970. renderOutline: boolean;
  66971. /** @hidden (Backing field) */
  66972. _renderOverlay: boolean;
  66973. /**
  66974. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66975. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66976. */
  66977. renderOverlay: boolean;
  66978. }
  66979. /**
  66980. * This class is responsible to draw bothe outline/overlay of meshes.
  66981. * It should not be used directly but through the available method on mesh.
  66982. */
  66983. export class OutlineRenderer implements ISceneComponent {
  66984. /**
  66985. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66986. */
  66987. private static _StencilReference;
  66988. /**
  66989. * The name of the component. Each component must have a unique name.
  66990. */
  66991. name: string;
  66992. /**
  66993. * The scene the component belongs to.
  66994. */
  66995. scene: Scene;
  66996. /**
  66997. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66998. */
  66999. zOffset: number;
  67000. private _engine;
  67001. private _effect;
  67002. private _cachedDefines;
  67003. private _savedDepthWrite;
  67004. /**
  67005. * Instantiates a new outline renderer. (There could be only one per scene).
  67006. * @param scene Defines the scene it belongs to
  67007. */
  67008. constructor(scene: Scene);
  67009. /**
  67010. * Register the component to one instance of a scene.
  67011. */
  67012. register(): void;
  67013. /**
  67014. * Rebuilds the elements related to this component in case of
  67015. * context lost for instance.
  67016. */
  67017. rebuild(): void;
  67018. /**
  67019. * Disposes the component and the associated ressources.
  67020. */
  67021. dispose(): void;
  67022. /**
  67023. * Renders the outline in the canvas.
  67024. * @param subMesh Defines the sumesh to render
  67025. * @param batch Defines the batch of meshes in case of instances
  67026. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67027. */
  67028. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67029. /**
  67030. * Returns whether or not the outline renderer is ready for a given submesh.
  67031. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67032. * @param subMesh Defines the submesh to check readyness for
  67033. * @param useInstances Defines wheter wee are trying to render instances or not
  67034. * @returns true if ready otherwise false
  67035. */
  67036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67037. private _beforeRenderingMesh;
  67038. private _afterRenderingMesh;
  67039. }
  67040. }
  67041. declare module BABYLON {
  67042. /**
  67043. * Defines the basic options interface of a Sprite Frame Source Size.
  67044. */
  67045. export interface ISpriteJSONSpriteSourceSize {
  67046. /**
  67047. * number of the original width of the Frame
  67048. */
  67049. w: number;
  67050. /**
  67051. * number of the original height of the Frame
  67052. */
  67053. h: number;
  67054. }
  67055. /**
  67056. * Defines the basic options interface of a Sprite Frame Data.
  67057. */
  67058. export interface ISpriteJSONSpriteFrameData {
  67059. /**
  67060. * number of the x offset of the Frame
  67061. */
  67062. x: number;
  67063. /**
  67064. * number of the y offset of the Frame
  67065. */
  67066. y: number;
  67067. /**
  67068. * number of the width of the Frame
  67069. */
  67070. w: number;
  67071. /**
  67072. * number of the height of the Frame
  67073. */
  67074. h: number;
  67075. }
  67076. /**
  67077. * Defines the basic options interface of a JSON Sprite.
  67078. */
  67079. export interface ISpriteJSONSprite {
  67080. /**
  67081. * string name of the Frame
  67082. */
  67083. filename: string;
  67084. /**
  67085. * ISpriteJSONSpriteFrame basic object of the frame data
  67086. */
  67087. frame: ISpriteJSONSpriteFrameData;
  67088. /**
  67089. * boolean to flag is the frame was rotated.
  67090. */
  67091. rotated: boolean;
  67092. /**
  67093. * boolean to flag is the frame was trimmed.
  67094. */
  67095. trimmed: boolean;
  67096. /**
  67097. * ISpriteJSONSpriteFrame basic object of the source data
  67098. */
  67099. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67100. /**
  67101. * ISpriteJSONSpriteFrame basic object of the source data
  67102. */
  67103. sourceSize: ISpriteJSONSpriteSourceSize;
  67104. }
  67105. /**
  67106. * Defines the basic options interface of a JSON atlas.
  67107. */
  67108. export interface ISpriteJSONAtlas {
  67109. /**
  67110. * Array of objects that contain the frame data.
  67111. */
  67112. frames: Array<ISpriteJSONSprite>;
  67113. /**
  67114. * object basic object containing the sprite meta data.
  67115. */
  67116. meta?: object;
  67117. }
  67118. }
  67119. declare module BABYLON {
  67120. /** @hidden */
  67121. export var spriteMapPixelShader: {
  67122. name: string;
  67123. shader: string;
  67124. };
  67125. }
  67126. declare module BABYLON {
  67127. /** @hidden */
  67128. export var spriteMapVertexShader: {
  67129. name: string;
  67130. shader: string;
  67131. };
  67132. }
  67133. declare module BABYLON {
  67134. /**
  67135. * Defines the basic options interface of a SpriteMap
  67136. */
  67137. export interface ISpriteMapOptions {
  67138. /**
  67139. * Vector2 of the number of cells in the grid.
  67140. */
  67141. stageSize?: Vector2;
  67142. /**
  67143. * Vector2 of the size of the output plane in World Units.
  67144. */
  67145. outputSize?: Vector2;
  67146. /**
  67147. * Vector3 of the position of the output plane in World Units.
  67148. */
  67149. outputPosition?: Vector3;
  67150. /**
  67151. * Vector3 of the rotation of the output plane.
  67152. */
  67153. outputRotation?: Vector3;
  67154. /**
  67155. * number of layers that the system will reserve in resources.
  67156. */
  67157. layerCount?: number;
  67158. /**
  67159. * number of max animation frames a single cell will reserve in resources.
  67160. */
  67161. maxAnimationFrames?: number;
  67162. /**
  67163. * number cell index of the base tile when the system compiles.
  67164. */
  67165. baseTile?: number;
  67166. /**
  67167. * boolean flip the sprite after its been repositioned by the framing data.
  67168. */
  67169. flipU?: boolean;
  67170. /**
  67171. * Vector3 scalar of the global RGB values of the SpriteMap.
  67172. */
  67173. colorMultiply?: Vector3;
  67174. }
  67175. /**
  67176. * Defines the IDisposable interface in order to be cleanable from resources.
  67177. */
  67178. export interface ISpriteMap extends IDisposable {
  67179. /**
  67180. * String name of the SpriteMap.
  67181. */
  67182. name: string;
  67183. /**
  67184. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67185. */
  67186. atlasJSON: ISpriteJSONAtlas;
  67187. /**
  67188. * Texture of the SpriteMap.
  67189. */
  67190. spriteSheet: Texture;
  67191. /**
  67192. * The parameters to initialize the SpriteMap with.
  67193. */
  67194. options: ISpriteMapOptions;
  67195. }
  67196. /**
  67197. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67198. */
  67199. export class SpriteMap implements ISpriteMap {
  67200. /** The Name of the spriteMap */
  67201. name: string;
  67202. /** The JSON file with the frame and meta data */
  67203. atlasJSON: ISpriteJSONAtlas;
  67204. /** The systems Sprite Sheet Texture */
  67205. spriteSheet: Texture;
  67206. /** Arguments passed with the Constructor */
  67207. options: ISpriteMapOptions;
  67208. /** Public Sprite Storage array, parsed from atlasJSON */
  67209. sprites: Array<ISpriteJSONSprite>;
  67210. /** Returns the Number of Sprites in the System */
  67211. get spriteCount(): number;
  67212. /** Returns the Position of Output Plane*/
  67213. get position(): Vector3;
  67214. /** Returns the Position of Output Plane*/
  67215. set position(v: Vector3);
  67216. /** Returns the Rotation of Output Plane*/
  67217. get rotation(): Vector3;
  67218. /** Returns the Rotation of Output Plane*/
  67219. set rotation(v: Vector3);
  67220. /** Sets the AnimationMap*/
  67221. get animationMap(): RawTexture;
  67222. /** Sets the AnimationMap*/
  67223. set animationMap(v: RawTexture);
  67224. /** Scene that the SpriteMap was created in */
  67225. private _scene;
  67226. /** Texture Buffer of Float32 that holds tile frame data*/
  67227. private _frameMap;
  67228. /** Texture Buffers of Float32 that holds tileMap data*/
  67229. private _tileMaps;
  67230. /** Texture Buffer of Float32 that holds Animation Data*/
  67231. private _animationMap;
  67232. /** Custom ShaderMaterial Central to the System*/
  67233. private _material;
  67234. /** Custom ShaderMaterial Central to the System*/
  67235. private _output;
  67236. /** Systems Time Ticker*/
  67237. private _time;
  67238. /**
  67239. * Creates a new SpriteMap
  67240. * @param name defines the SpriteMaps Name
  67241. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67242. * @param spriteSheet is the Texture that the Sprites are on.
  67243. * @param options a basic deployment configuration
  67244. * @param scene The Scene that the map is deployed on
  67245. */
  67246. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67247. /**
  67248. * Returns tileID location
  67249. * @returns Vector2 the cell position ID
  67250. */
  67251. getTileID(): Vector2;
  67252. /**
  67253. * Gets the UV location of the mouse over the SpriteMap.
  67254. * @returns Vector2 the UV position of the mouse interaction
  67255. */
  67256. getMousePosition(): Vector2;
  67257. /**
  67258. * Creates the "frame" texture Buffer
  67259. * -------------------------------------
  67260. * Structure of frames
  67261. * "filename": "Falling-Water-2.png",
  67262. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67263. * "rotated": true,
  67264. * "trimmed": true,
  67265. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67266. * "sourceSize": {"w":32,"h":32}
  67267. * @returns RawTexture of the frameMap
  67268. */
  67269. private _createFrameBuffer;
  67270. /**
  67271. * Creates the tileMap texture Buffer
  67272. * @param buffer normally and array of numbers, or a false to generate from scratch
  67273. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67274. * @returns RawTexture of the tileMap
  67275. */
  67276. private _createTileBuffer;
  67277. /**
  67278. * Modifies the data of the tileMaps
  67279. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67280. * @param pos is the iVector2 Coordinates of the Tile
  67281. * @param tile The SpriteIndex of the new Tile
  67282. */
  67283. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67284. /**
  67285. * Creates the animationMap texture Buffer
  67286. * @param buffer normally and array of numbers, or a false to generate from scratch
  67287. * @returns RawTexture of the animationMap
  67288. */
  67289. private _createTileAnimationBuffer;
  67290. /**
  67291. * Modifies the data of the animationMap
  67292. * @param cellID is the Index of the Sprite
  67293. * @param _frame is the target Animation frame
  67294. * @param toCell is the Target Index of the next frame of the animation
  67295. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67296. * @param speed is a global scalar of the time variable on the map.
  67297. */
  67298. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67299. /**
  67300. * Exports the .tilemaps file
  67301. */
  67302. saveTileMaps(): void;
  67303. /**
  67304. * Imports the .tilemaps file
  67305. * @param url of the .tilemaps file
  67306. */
  67307. loadTileMaps(url: string): void;
  67308. /**
  67309. * Release associated resources
  67310. */
  67311. dispose(): void;
  67312. }
  67313. }
  67314. declare module BABYLON {
  67315. /**
  67316. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67317. * @see http://doc.babylonjs.com/babylon101/sprites
  67318. */
  67319. export class SpritePackedManager extends SpriteManager {
  67320. /** defines the packed manager's name */
  67321. name: string;
  67322. /**
  67323. * Creates a new sprite manager from a packed sprite sheet
  67324. * @param name defines the manager's name
  67325. * @param imgUrl defines the sprite sheet url
  67326. * @param capacity defines the maximum allowed number of sprites
  67327. * @param scene defines the hosting scene
  67328. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67329. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67330. * @param samplingMode defines the smapling mode to use with spritesheet
  67331. * @param fromPacked set to true; do not alter
  67332. */
  67333. constructor(
  67334. /** defines the packed manager's name */
  67335. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67336. }
  67337. }
  67338. declare module BABYLON {
  67339. /**
  67340. * Defines the list of states available for a task inside a AssetsManager
  67341. */
  67342. export enum AssetTaskState {
  67343. /**
  67344. * Initialization
  67345. */
  67346. INIT = 0,
  67347. /**
  67348. * Running
  67349. */
  67350. RUNNING = 1,
  67351. /**
  67352. * Done
  67353. */
  67354. DONE = 2,
  67355. /**
  67356. * Error
  67357. */
  67358. ERROR = 3
  67359. }
  67360. /**
  67361. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67362. */
  67363. export abstract class AbstractAssetTask {
  67364. /**
  67365. * Task name
  67366. */ name: string;
  67367. /**
  67368. * Callback called when the task is successful
  67369. */
  67370. onSuccess: (task: any) => void;
  67371. /**
  67372. * Callback called when the task is not successful
  67373. */
  67374. onError: (task: any, message?: string, exception?: any) => void;
  67375. /**
  67376. * Creates a new AssetsManager
  67377. * @param name defines the name of the task
  67378. */
  67379. constructor(
  67380. /**
  67381. * Task name
  67382. */ name: string);
  67383. private _isCompleted;
  67384. private _taskState;
  67385. private _errorObject;
  67386. /**
  67387. * Get if the task is completed
  67388. */
  67389. get isCompleted(): boolean;
  67390. /**
  67391. * Gets the current state of the task
  67392. */
  67393. get taskState(): AssetTaskState;
  67394. /**
  67395. * Gets the current error object (if task is in error)
  67396. */
  67397. get errorObject(): {
  67398. message?: string;
  67399. exception?: any;
  67400. };
  67401. /**
  67402. * Internal only
  67403. * @hidden
  67404. */
  67405. _setErrorObject(message?: string, exception?: any): void;
  67406. /**
  67407. * Execute the current task
  67408. * @param scene defines the scene where you want your assets to be loaded
  67409. * @param onSuccess is a callback called when the task is successfully executed
  67410. * @param onError is a callback called if an error occurs
  67411. */
  67412. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67413. /**
  67414. * Execute the current task
  67415. * @param scene defines the scene where you want your assets to be loaded
  67416. * @param onSuccess is a callback called when the task is successfully executed
  67417. * @param onError is a callback called if an error occurs
  67418. */
  67419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67420. /**
  67421. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67422. * This can be used with failed tasks that have the reason for failure fixed.
  67423. */
  67424. reset(): void;
  67425. private onErrorCallback;
  67426. private onDoneCallback;
  67427. }
  67428. /**
  67429. * Define the interface used by progress events raised during assets loading
  67430. */
  67431. export interface IAssetsProgressEvent {
  67432. /**
  67433. * Defines the number of remaining tasks to process
  67434. */
  67435. remainingCount: number;
  67436. /**
  67437. * Defines the total number of tasks
  67438. */
  67439. totalCount: number;
  67440. /**
  67441. * Defines the task that was just processed
  67442. */
  67443. task: AbstractAssetTask;
  67444. }
  67445. /**
  67446. * Class used to share progress information about assets loading
  67447. */
  67448. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67449. /**
  67450. * Defines the number of remaining tasks to process
  67451. */
  67452. remainingCount: number;
  67453. /**
  67454. * Defines the total number of tasks
  67455. */
  67456. totalCount: number;
  67457. /**
  67458. * Defines the task that was just processed
  67459. */
  67460. task: AbstractAssetTask;
  67461. /**
  67462. * Creates a AssetsProgressEvent
  67463. * @param remainingCount defines the number of remaining tasks to process
  67464. * @param totalCount defines the total number of tasks
  67465. * @param task defines the task that was just processed
  67466. */
  67467. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67468. }
  67469. /**
  67470. * Define a task used by AssetsManager to load meshes
  67471. */
  67472. export class MeshAssetTask extends AbstractAssetTask {
  67473. /**
  67474. * Defines the name of the task
  67475. */
  67476. name: string;
  67477. /**
  67478. * Defines the list of mesh's names you want to load
  67479. */
  67480. meshesNames: any;
  67481. /**
  67482. * Defines the root url to use as a base to load your meshes and associated resources
  67483. */
  67484. rootUrl: string;
  67485. /**
  67486. * Defines the filename of the scene to load from
  67487. */
  67488. sceneFilename: string;
  67489. /**
  67490. * Gets the list of loaded meshes
  67491. */
  67492. loadedMeshes: Array<AbstractMesh>;
  67493. /**
  67494. * Gets the list of loaded particle systems
  67495. */
  67496. loadedParticleSystems: Array<IParticleSystem>;
  67497. /**
  67498. * Gets the list of loaded skeletons
  67499. */
  67500. loadedSkeletons: Array<Skeleton>;
  67501. /**
  67502. * Gets the list of loaded animation groups
  67503. */
  67504. loadedAnimationGroups: Array<AnimationGroup>;
  67505. /**
  67506. * Callback called when the task is successful
  67507. */
  67508. onSuccess: (task: MeshAssetTask) => void;
  67509. /**
  67510. * Callback called when the task is successful
  67511. */
  67512. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67513. /**
  67514. * Creates a new MeshAssetTask
  67515. * @param name defines the name of the task
  67516. * @param meshesNames defines the list of mesh's names you want to load
  67517. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67518. * @param sceneFilename defines the filename of the scene to load from
  67519. */
  67520. constructor(
  67521. /**
  67522. * Defines the name of the task
  67523. */
  67524. name: string,
  67525. /**
  67526. * Defines the list of mesh's names you want to load
  67527. */
  67528. meshesNames: any,
  67529. /**
  67530. * Defines the root url to use as a base to load your meshes and associated resources
  67531. */
  67532. rootUrl: string,
  67533. /**
  67534. * Defines the filename of the scene to load from
  67535. */
  67536. sceneFilename: string);
  67537. /**
  67538. * Execute the current task
  67539. * @param scene defines the scene where you want your assets to be loaded
  67540. * @param onSuccess is a callback called when the task is successfully executed
  67541. * @param onError is a callback called if an error occurs
  67542. */
  67543. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67544. }
  67545. /**
  67546. * Define a task used by AssetsManager to load text content
  67547. */
  67548. export class TextFileAssetTask extends AbstractAssetTask {
  67549. /**
  67550. * Defines the name of the task
  67551. */
  67552. name: string;
  67553. /**
  67554. * Defines the location of the file to load
  67555. */
  67556. url: string;
  67557. /**
  67558. * Gets the loaded text string
  67559. */
  67560. text: string;
  67561. /**
  67562. * Callback called when the task is successful
  67563. */
  67564. onSuccess: (task: TextFileAssetTask) => void;
  67565. /**
  67566. * Callback called when the task is successful
  67567. */
  67568. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67569. /**
  67570. * Creates a new TextFileAssetTask object
  67571. * @param name defines the name of the task
  67572. * @param url defines the location of the file to load
  67573. */
  67574. constructor(
  67575. /**
  67576. * Defines the name of the task
  67577. */
  67578. name: string,
  67579. /**
  67580. * Defines the location of the file to load
  67581. */
  67582. url: string);
  67583. /**
  67584. * Execute the current task
  67585. * @param scene defines the scene where you want your assets to be loaded
  67586. * @param onSuccess is a callback called when the task is successfully executed
  67587. * @param onError is a callback called if an error occurs
  67588. */
  67589. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67590. }
  67591. /**
  67592. * Define a task used by AssetsManager to load binary data
  67593. */
  67594. export class BinaryFileAssetTask extends AbstractAssetTask {
  67595. /**
  67596. * Defines the name of the task
  67597. */
  67598. name: string;
  67599. /**
  67600. * Defines the location of the file to load
  67601. */
  67602. url: string;
  67603. /**
  67604. * Gets the lodaded data (as an array buffer)
  67605. */
  67606. data: ArrayBuffer;
  67607. /**
  67608. * Callback called when the task is successful
  67609. */
  67610. onSuccess: (task: BinaryFileAssetTask) => void;
  67611. /**
  67612. * Callback called when the task is successful
  67613. */
  67614. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67615. /**
  67616. * Creates a new BinaryFileAssetTask object
  67617. * @param name defines the name of the new task
  67618. * @param url defines the location of the file to load
  67619. */
  67620. constructor(
  67621. /**
  67622. * Defines the name of the task
  67623. */
  67624. name: string,
  67625. /**
  67626. * Defines the location of the file to load
  67627. */
  67628. url: string);
  67629. /**
  67630. * Execute the current task
  67631. * @param scene defines the scene where you want your assets to be loaded
  67632. * @param onSuccess is a callback called when the task is successfully executed
  67633. * @param onError is a callback called if an error occurs
  67634. */
  67635. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67636. }
  67637. /**
  67638. * Define a task used by AssetsManager to load images
  67639. */
  67640. export class ImageAssetTask extends AbstractAssetTask {
  67641. /**
  67642. * Defines the name of the task
  67643. */
  67644. name: string;
  67645. /**
  67646. * Defines the location of the image to load
  67647. */
  67648. url: string;
  67649. /**
  67650. * Gets the loaded images
  67651. */
  67652. image: HTMLImageElement;
  67653. /**
  67654. * Callback called when the task is successful
  67655. */
  67656. onSuccess: (task: ImageAssetTask) => void;
  67657. /**
  67658. * Callback called when the task is successful
  67659. */
  67660. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67661. /**
  67662. * Creates a new ImageAssetTask
  67663. * @param name defines the name of the task
  67664. * @param url defines the location of the image to load
  67665. */
  67666. constructor(
  67667. /**
  67668. * Defines the name of the task
  67669. */
  67670. name: string,
  67671. /**
  67672. * Defines the location of the image to load
  67673. */
  67674. url: string);
  67675. /**
  67676. * Execute the current task
  67677. * @param scene defines the scene where you want your assets to be loaded
  67678. * @param onSuccess is a callback called when the task is successfully executed
  67679. * @param onError is a callback called if an error occurs
  67680. */
  67681. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67682. }
  67683. /**
  67684. * Defines the interface used by texture loading tasks
  67685. */
  67686. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67687. /**
  67688. * Gets the loaded texture
  67689. */
  67690. texture: TEX;
  67691. }
  67692. /**
  67693. * Define a task used by AssetsManager to load 2D textures
  67694. */
  67695. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67696. /**
  67697. * Defines the name of the task
  67698. */
  67699. name: string;
  67700. /**
  67701. * Defines the location of the file to load
  67702. */
  67703. url: string;
  67704. /**
  67705. * Defines if mipmap should not be generated (default is false)
  67706. */
  67707. noMipmap?: boolean | undefined;
  67708. /**
  67709. * Defines if texture must be inverted on Y axis (default is false)
  67710. */
  67711. invertY?: boolean | undefined;
  67712. /**
  67713. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67714. */
  67715. samplingMode: number;
  67716. /**
  67717. * Gets the loaded texture
  67718. */
  67719. texture: Texture;
  67720. /**
  67721. * Callback called when the task is successful
  67722. */
  67723. onSuccess: (task: TextureAssetTask) => void;
  67724. /**
  67725. * Callback called when the task is successful
  67726. */
  67727. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67728. /**
  67729. * Creates a new TextureAssetTask object
  67730. * @param name defines the name of the task
  67731. * @param url defines the location of the file to load
  67732. * @param noMipmap defines if mipmap should not be generated (default is false)
  67733. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67734. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67735. */
  67736. constructor(
  67737. /**
  67738. * Defines the name of the task
  67739. */
  67740. name: string,
  67741. /**
  67742. * Defines the location of the file to load
  67743. */
  67744. url: string,
  67745. /**
  67746. * Defines if mipmap should not be generated (default is false)
  67747. */
  67748. noMipmap?: boolean | undefined,
  67749. /**
  67750. * Defines if texture must be inverted on Y axis (default is false)
  67751. */
  67752. invertY?: boolean | undefined,
  67753. /**
  67754. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67755. */
  67756. samplingMode?: number);
  67757. /**
  67758. * Execute the current task
  67759. * @param scene defines the scene where you want your assets to be loaded
  67760. * @param onSuccess is a callback called when the task is successfully executed
  67761. * @param onError is a callback called if an error occurs
  67762. */
  67763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67764. }
  67765. /**
  67766. * Define a task used by AssetsManager to load cube textures
  67767. */
  67768. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67769. /**
  67770. * Defines the name of the task
  67771. */
  67772. name: string;
  67773. /**
  67774. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67775. */
  67776. url: string;
  67777. /**
  67778. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67779. */
  67780. extensions?: string[] | undefined;
  67781. /**
  67782. * Defines if mipmaps should not be generated (default is false)
  67783. */
  67784. noMipmap?: boolean | undefined;
  67785. /**
  67786. * Defines the explicit list of files (undefined by default)
  67787. */
  67788. files?: string[] | undefined;
  67789. /**
  67790. * Gets the loaded texture
  67791. */
  67792. texture: CubeTexture;
  67793. /**
  67794. * Callback called when the task is successful
  67795. */
  67796. onSuccess: (task: CubeTextureAssetTask) => void;
  67797. /**
  67798. * Callback called when the task is successful
  67799. */
  67800. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67801. /**
  67802. * Creates a new CubeTextureAssetTask
  67803. * @param name defines the name of the task
  67804. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67805. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67806. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67807. * @param files defines the explicit list of files (undefined by default)
  67808. */
  67809. constructor(
  67810. /**
  67811. * Defines the name of the task
  67812. */
  67813. name: string,
  67814. /**
  67815. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67816. */
  67817. url: string,
  67818. /**
  67819. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67820. */
  67821. extensions?: string[] | undefined,
  67822. /**
  67823. * Defines if mipmaps should not be generated (default is false)
  67824. */
  67825. noMipmap?: boolean | undefined,
  67826. /**
  67827. * Defines the explicit list of files (undefined by default)
  67828. */
  67829. files?: string[] | undefined);
  67830. /**
  67831. * Execute the current task
  67832. * @param scene defines the scene where you want your assets to be loaded
  67833. * @param onSuccess is a callback called when the task is successfully executed
  67834. * @param onError is a callback called if an error occurs
  67835. */
  67836. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67837. }
  67838. /**
  67839. * Define a task used by AssetsManager to load HDR cube textures
  67840. */
  67841. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67842. /**
  67843. * Defines the name of the task
  67844. */
  67845. name: string;
  67846. /**
  67847. * Defines the location of the file to load
  67848. */
  67849. url: string;
  67850. /**
  67851. * Defines the desired size (the more it increases the longer the generation will be)
  67852. */
  67853. size: number;
  67854. /**
  67855. * Defines if mipmaps should not be generated (default is false)
  67856. */
  67857. noMipmap: boolean;
  67858. /**
  67859. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67860. */
  67861. generateHarmonics: boolean;
  67862. /**
  67863. * 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)
  67864. */
  67865. gammaSpace: boolean;
  67866. /**
  67867. * Internal Use Only
  67868. */
  67869. reserved: boolean;
  67870. /**
  67871. * Gets the loaded texture
  67872. */
  67873. texture: HDRCubeTexture;
  67874. /**
  67875. * Callback called when the task is successful
  67876. */
  67877. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67878. /**
  67879. * Callback called when the task is successful
  67880. */
  67881. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67882. /**
  67883. * Creates a new HDRCubeTextureAssetTask object
  67884. * @param name defines the name of the task
  67885. * @param url defines the location of the file to load
  67886. * @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.
  67887. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67888. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67889. * @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)
  67890. * @param reserved Internal use only
  67891. */
  67892. constructor(
  67893. /**
  67894. * Defines the name of the task
  67895. */
  67896. name: string,
  67897. /**
  67898. * Defines the location of the file to load
  67899. */
  67900. url: string,
  67901. /**
  67902. * Defines the desired size (the more it increases the longer the generation will be)
  67903. */
  67904. size: number,
  67905. /**
  67906. * Defines if mipmaps should not be generated (default is false)
  67907. */
  67908. noMipmap?: boolean,
  67909. /**
  67910. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67911. */
  67912. generateHarmonics?: boolean,
  67913. /**
  67914. * 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)
  67915. */
  67916. gammaSpace?: boolean,
  67917. /**
  67918. * Internal Use Only
  67919. */
  67920. reserved?: boolean);
  67921. /**
  67922. * Execute the current task
  67923. * @param scene defines the scene where you want your assets to be loaded
  67924. * @param onSuccess is a callback called when the task is successfully executed
  67925. * @param onError is a callback called if an error occurs
  67926. */
  67927. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67928. }
  67929. /**
  67930. * Define a task used by AssetsManager to load Equirectangular cube textures
  67931. */
  67932. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67933. /**
  67934. * Defines the name of the task
  67935. */
  67936. name: string;
  67937. /**
  67938. * Defines the location of the file to load
  67939. */
  67940. url: string;
  67941. /**
  67942. * Defines the desired size (the more it increases the longer the generation will be)
  67943. */
  67944. size: number;
  67945. /**
  67946. * Defines if mipmaps should not be generated (default is false)
  67947. */
  67948. noMipmap: boolean;
  67949. /**
  67950. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67951. * but the standard material would require them in Gamma space) (default is true)
  67952. */
  67953. gammaSpace: boolean;
  67954. /**
  67955. * Gets the loaded texture
  67956. */
  67957. texture: EquiRectangularCubeTexture;
  67958. /**
  67959. * Callback called when the task is successful
  67960. */
  67961. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67962. /**
  67963. * Callback called when the task is successful
  67964. */
  67965. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67966. /**
  67967. * Creates a new EquiRectangularCubeTextureAssetTask object
  67968. * @param name defines the name of the task
  67969. * @param url defines the location of the file to load
  67970. * @param size defines the desired size (the more it increases the longer the generation will be)
  67971. * If the size is omitted this implies you are using a preprocessed cubemap.
  67972. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67973. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67974. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67975. * (default is true)
  67976. */
  67977. constructor(
  67978. /**
  67979. * Defines the name of the task
  67980. */
  67981. name: string,
  67982. /**
  67983. * Defines the location of the file to load
  67984. */
  67985. url: string,
  67986. /**
  67987. * Defines the desired size (the more it increases the longer the generation will be)
  67988. */
  67989. size: number,
  67990. /**
  67991. * Defines if mipmaps should not be generated (default is false)
  67992. */
  67993. noMipmap?: boolean,
  67994. /**
  67995. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67996. * but the standard material would require them in Gamma space) (default is true)
  67997. */
  67998. gammaSpace?: boolean);
  67999. /**
  68000. * Execute the current task
  68001. * @param scene defines the scene where you want your assets to be loaded
  68002. * @param onSuccess is a callback called when the task is successfully executed
  68003. * @param onError is a callback called if an error occurs
  68004. */
  68005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68006. }
  68007. /**
  68008. * This class can be used to easily import assets into a scene
  68009. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68010. */
  68011. export class AssetsManager {
  68012. private _scene;
  68013. private _isLoading;
  68014. protected _tasks: AbstractAssetTask[];
  68015. protected _waitingTasksCount: number;
  68016. protected _totalTasksCount: number;
  68017. /**
  68018. * Callback called when all tasks are processed
  68019. */
  68020. onFinish: (tasks: AbstractAssetTask[]) => void;
  68021. /**
  68022. * Callback called when a task is successful
  68023. */
  68024. onTaskSuccess: (task: AbstractAssetTask) => void;
  68025. /**
  68026. * Callback called when a task had an error
  68027. */
  68028. onTaskError: (task: AbstractAssetTask) => void;
  68029. /**
  68030. * Callback called when a task is done (whatever the result is)
  68031. */
  68032. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68033. /**
  68034. * Observable called when all tasks are processed
  68035. */
  68036. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68037. /**
  68038. * Observable called when a task had an error
  68039. */
  68040. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68041. /**
  68042. * Observable called when all tasks were executed
  68043. */
  68044. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68045. /**
  68046. * Observable called when a task is done (whatever the result is)
  68047. */
  68048. onProgressObservable: Observable<IAssetsProgressEvent>;
  68049. /**
  68050. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68051. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68052. */
  68053. useDefaultLoadingScreen: boolean;
  68054. /**
  68055. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68056. * when all assets have been downloaded.
  68057. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68058. */
  68059. autoHideLoadingUI: boolean;
  68060. /**
  68061. * Creates a new AssetsManager
  68062. * @param scene defines the scene to work on
  68063. */
  68064. constructor(scene: Scene);
  68065. /**
  68066. * Add a MeshAssetTask to the list of active tasks
  68067. * @param taskName defines the name of the new task
  68068. * @param meshesNames defines the name of meshes to load
  68069. * @param rootUrl defines the root url to use to locate files
  68070. * @param sceneFilename defines the filename of the scene file
  68071. * @returns a new MeshAssetTask object
  68072. */
  68073. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68074. /**
  68075. * Add a TextFileAssetTask to the list of active tasks
  68076. * @param taskName defines the name of the new task
  68077. * @param url defines the url of the file to load
  68078. * @returns a new TextFileAssetTask object
  68079. */
  68080. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68081. /**
  68082. * Add a BinaryFileAssetTask to the list of active tasks
  68083. * @param taskName defines the name of the new task
  68084. * @param url defines the url of the file to load
  68085. * @returns a new BinaryFileAssetTask object
  68086. */
  68087. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68088. /**
  68089. * Add a ImageAssetTask to the list of active tasks
  68090. * @param taskName defines the name of the new task
  68091. * @param url defines the url of the file to load
  68092. * @returns a new ImageAssetTask object
  68093. */
  68094. addImageTask(taskName: string, url: string): ImageAssetTask;
  68095. /**
  68096. * Add a TextureAssetTask to the list of active tasks
  68097. * @param taskName defines the name of the new task
  68098. * @param url defines the url of the file to load
  68099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68100. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68101. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68102. * @returns a new TextureAssetTask object
  68103. */
  68104. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68105. /**
  68106. * Add a CubeTextureAssetTask to the list of active tasks
  68107. * @param taskName defines the name of the new task
  68108. * @param url defines the url of the file to load
  68109. * @param extensions defines the extension to use to load the cube map (can be null)
  68110. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68111. * @param files defines the list of files to load (can be null)
  68112. * @returns a new CubeTextureAssetTask object
  68113. */
  68114. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68115. /**
  68116. *
  68117. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68118. * @param taskName defines the name of the new task
  68119. * @param url defines the url of the file to load
  68120. * @param size defines the size you want for the cubemap (can be null)
  68121. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68122. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68123. * @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)
  68124. * @param reserved Internal use only
  68125. * @returns a new HDRCubeTextureAssetTask object
  68126. */
  68127. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68128. /**
  68129. *
  68130. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68131. * @param taskName defines the name of the new task
  68132. * @param url defines the url of the file to load
  68133. * @param size defines the size you want for the cubemap (can be null)
  68134. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68135. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68136. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68137. * @returns a new EquiRectangularCubeTextureAssetTask object
  68138. */
  68139. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68140. /**
  68141. * Remove a task from the assets manager.
  68142. * @param task the task to remove
  68143. */
  68144. removeTask(task: AbstractAssetTask): void;
  68145. private _decreaseWaitingTasksCount;
  68146. private _runTask;
  68147. /**
  68148. * Reset the AssetsManager and remove all tasks
  68149. * @return the current instance of the AssetsManager
  68150. */
  68151. reset(): AssetsManager;
  68152. /**
  68153. * Start the loading process
  68154. * @return the current instance of the AssetsManager
  68155. */
  68156. load(): AssetsManager;
  68157. /**
  68158. * Start the loading process as an async operation
  68159. * @return a promise returning the list of failed tasks
  68160. */
  68161. loadAsync(): Promise<void>;
  68162. }
  68163. }
  68164. declare module BABYLON {
  68165. /**
  68166. * Wrapper class for promise with external resolve and reject.
  68167. */
  68168. export class Deferred<T> {
  68169. /**
  68170. * The promise associated with this deferred object.
  68171. */
  68172. readonly promise: Promise<T>;
  68173. private _resolve;
  68174. private _reject;
  68175. /**
  68176. * The resolve method of the promise associated with this deferred object.
  68177. */
  68178. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68179. /**
  68180. * The reject method of the promise associated with this deferred object.
  68181. */
  68182. get reject(): (reason?: any) => void;
  68183. /**
  68184. * Constructor for this deferred object.
  68185. */
  68186. constructor();
  68187. }
  68188. }
  68189. declare module BABYLON {
  68190. /**
  68191. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68192. */
  68193. export class MeshExploder {
  68194. private _centerMesh;
  68195. private _meshes;
  68196. private _meshesOrigins;
  68197. private _toCenterVectors;
  68198. private _scaledDirection;
  68199. private _newPosition;
  68200. private _centerPosition;
  68201. /**
  68202. * Explodes meshes from a center mesh.
  68203. * @param meshes The meshes to explode.
  68204. * @param centerMesh The mesh to be center of explosion.
  68205. */
  68206. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68207. private _setCenterMesh;
  68208. /**
  68209. * Get class name
  68210. * @returns "MeshExploder"
  68211. */
  68212. getClassName(): string;
  68213. /**
  68214. * "Exploded meshes"
  68215. * @returns Array of meshes with the centerMesh at index 0.
  68216. */
  68217. getMeshes(): Array<Mesh>;
  68218. /**
  68219. * Explodes meshes giving a specific direction
  68220. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68221. */
  68222. explode(direction?: number): void;
  68223. }
  68224. }
  68225. declare module BABYLON {
  68226. /**
  68227. * Class used to help managing file picking and drag'n'drop
  68228. */
  68229. export class FilesInput {
  68230. /**
  68231. * List of files ready to be loaded
  68232. */
  68233. static get FilesToLoad(): {
  68234. [key: string]: File;
  68235. };
  68236. /**
  68237. * Callback called when a file is processed
  68238. */
  68239. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68240. private _engine;
  68241. private _currentScene;
  68242. private _sceneLoadedCallback;
  68243. private _progressCallback;
  68244. private _additionalRenderLoopLogicCallback;
  68245. private _textureLoadingCallback;
  68246. private _startingProcessingFilesCallback;
  68247. private _onReloadCallback;
  68248. private _errorCallback;
  68249. private _elementToMonitor;
  68250. private _sceneFileToLoad;
  68251. private _filesToLoad;
  68252. /**
  68253. * Creates a new FilesInput
  68254. * @param engine defines the rendering engine
  68255. * @param scene defines the hosting scene
  68256. * @param sceneLoadedCallback callback called when scene is loaded
  68257. * @param progressCallback callback called to track progress
  68258. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68259. * @param textureLoadingCallback callback called when a texture is loading
  68260. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68261. * @param onReloadCallback callback called when a reload is requested
  68262. * @param errorCallback callback call if an error occurs
  68263. */
  68264. 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);
  68265. private _dragEnterHandler;
  68266. private _dragOverHandler;
  68267. private _dropHandler;
  68268. /**
  68269. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68270. * @param elementToMonitor defines the DOM element to track
  68271. */
  68272. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68273. /**
  68274. * Release all associated resources
  68275. */
  68276. dispose(): void;
  68277. private renderFunction;
  68278. private drag;
  68279. private drop;
  68280. private _traverseFolder;
  68281. private _processFiles;
  68282. /**
  68283. * Load files from a drop event
  68284. * @param event defines the drop event to use as source
  68285. */
  68286. loadFiles(event: any): void;
  68287. private _processReload;
  68288. /**
  68289. * Reload the current scene from the loaded files
  68290. */
  68291. reload(): void;
  68292. }
  68293. }
  68294. declare module BABYLON {
  68295. /**
  68296. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68298. */
  68299. export class SceneOptimization {
  68300. /**
  68301. * Defines the priority of this optimization (0 by default which means first in the list)
  68302. */
  68303. priority: number;
  68304. /**
  68305. * Gets a string describing the action executed by the current optimization
  68306. * @returns description string
  68307. */
  68308. getDescription(): string;
  68309. /**
  68310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68311. * @param scene defines the current scene where to apply this optimization
  68312. * @param optimizer defines the current optimizer
  68313. * @returns true if everything that can be done was applied
  68314. */
  68315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68316. /**
  68317. * Creates the SceneOptimization object
  68318. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68319. * @param desc defines the description associated with the optimization
  68320. */
  68321. constructor(
  68322. /**
  68323. * Defines the priority of this optimization (0 by default which means first in the list)
  68324. */
  68325. priority?: number);
  68326. }
  68327. /**
  68328. * Defines an optimization used to reduce the size of render target textures
  68329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68330. */
  68331. export class TextureOptimization extends SceneOptimization {
  68332. /**
  68333. * Defines the priority of this optimization (0 by default which means first in the list)
  68334. */
  68335. priority: number;
  68336. /**
  68337. * 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
  68338. */
  68339. maximumSize: number;
  68340. /**
  68341. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68342. */
  68343. step: number;
  68344. /**
  68345. * Gets a string describing the action executed by the current optimization
  68346. * @returns description string
  68347. */
  68348. getDescription(): string;
  68349. /**
  68350. * Creates the TextureOptimization object
  68351. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68352. * @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
  68353. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68354. */
  68355. constructor(
  68356. /**
  68357. * Defines the priority of this optimization (0 by default which means first in the list)
  68358. */
  68359. priority?: number,
  68360. /**
  68361. * 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
  68362. */
  68363. maximumSize?: number,
  68364. /**
  68365. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68366. */
  68367. step?: number);
  68368. /**
  68369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68370. * @param scene defines the current scene where to apply this optimization
  68371. * @param optimizer defines the current optimizer
  68372. * @returns true if everything that can be done was applied
  68373. */
  68374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68375. }
  68376. /**
  68377. * Defines an optimization used to increase or decrease the rendering resolution
  68378. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68379. */
  68380. export class HardwareScalingOptimization extends SceneOptimization {
  68381. /**
  68382. * Defines the priority of this optimization (0 by default which means first in the list)
  68383. */
  68384. priority: number;
  68385. /**
  68386. * Defines the maximum scale to use (2 by default)
  68387. */
  68388. maximumScale: number;
  68389. /**
  68390. * Defines the step to use between two passes (0.5 by default)
  68391. */
  68392. step: number;
  68393. private _currentScale;
  68394. private _directionOffset;
  68395. /**
  68396. * Gets a string describing the action executed by the current optimization
  68397. * @return description string
  68398. */
  68399. getDescription(): string;
  68400. /**
  68401. * Creates the HardwareScalingOptimization object
  68402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68403. * @param maximumScale defines the maximum scale to use (2 by default)
  68404. * @param step defines the step to use between two passes (0.5 by default)
  68405. */
  68406. constructor(
  68407. /**
  68408. * Defines the priority of this optimization (0 by default which means first in the list)
  68409. */
  68410. priority?: number,
  68411. /**
  68412. * Defines the maximum scale to use (2 by default)
  68413. */
  68414. maximumScale?: number,
  68415. /**
  68416. * Defines the step to use between two passes (0.5 by default)
  68417. */
  68418. step?: number);
  68419. /**
  68420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68421. * @param scene defines the current scene where to apply this optimization
  68422. * @param optimizer defines the current optimizer
  68423. * @returns true if everything that can be done was applied
  68424. */
  68425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68426. }
  68427. /**
  68428. * Defines an optimization used to remove shadows
  68429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68430. */
  68431. export class ShadowsOptimization extends SceneOptimization {
  68432. /**
  68433. * Gets a string describing the action executed by the current optimization
  68434. * @return description string
  68435. */
  68436. getDescription(): string;
  68437. /**
  68438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68439. * @param scene defines the current scene where to apply this optimization
  68440. * @param optimizer defines the current optimizer
  68441. * @returns true if everything that can be done was applied
  68442. */
  68443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68444. }
  68445. /**
  68446. * Defines an optimization used to turn post-processes off
  68447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68448. */
  68449. export class PostProcessesOptimization extends SceneOptimization {
  68450. /**
  68451. * Gets a string describing the action executed by the current optimization
  68452. * @return description string
  68453. */
  68454. getDescription(): string;
  68455. /**
  68456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68457. * @param scene defines the current scene where to apply this optimization
  68458. * @param optimizer defines the current optimizer
  68459. * @returns true if everything that can be done was applied
  68460. */
  68461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68462. }
  68463. /**
  68464. * Defines an optimization used to turn lens flares off
  68465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68466. */
  68467. export class LensFlaresOptimization extends SceneOptimization {
  68468. /**
  68469. * Gets a string describing the action executed by the current optimization
  68470. * @return description string
  68471. */
  68472. getDescription(): string;
  68473. /**
  68474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68475. * @param scene defines the current scene where to apply this optimization
  68476. * @param optimizer defines the current optimizer
  68477. * @returns true if everything that can be done was applied
  68478. */
  68479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68480. }
  68481. /**
  68482. * Defines an optimization based on user defined callback.
  68483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68484. */
  68485. export class CustomOptimization extends SceneOptimization {
  68486. /**
  68487. * Callback called to apply the custom optimization.
  68488. */
  68489. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68490. /**
  68491. * Callback called to get custom description
  68492. */
  68493. onGetDescription: () => string;
  68494. /**
  68495. * Gets a string describing the action executed by the current optimization
  68496. * @returns description string
  68497. */
  68498. getDescription(): string;
  68499. /**
  68500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68501. * @param scene defines the current scene where to apply this optimization
  68502. * @param optimizer defines the current optimizer
  68503. * @returns true if everything that can be done was applied
  68504. */
  68505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68506. }
  68507. /**
  68508. * Defines an optimization used to turn particles off
  68509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68510. */
  68511. export class ParticlesOptimization extends SceneOptimization {
  68512. /**
  68513. * Gets a string describing the action executed by the current optimization
  68514. * @return description string
  68515. */
  68516. getDescription(): string;
  68517. /**
  68518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68519. * @param scene defines the current scene where to apply this optimization
  68520. * @param optimizer defines the current optimizer
  68521. * @returns true if everything that can be done was applied
  68522. */
  68523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68524. }
  68525. /**
  68526. * Defines an optimization used to turn render targets off
  68527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68528. */
  68529. export class RenderTargetsOptimization extends SceneOptimization {
  68530. /**
  68531. * Gets a string describing the action executed by the current optimization
  68532. * @return description string
  68533. */
  68534. getDescription(): string;
  68535. /**
  68536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68537. * @param scene defines the current scene where to apply this optimization
  68538. * @param optimizer defines the current optimizer
  68539. * @returns true if everything that can be done was applied
  68540. */
  68541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68542. }
  68543. /**
  68544. * Defines an optimization used to merge meshes with compatible materials
  68545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68546. */
  68547. export class MergeMeshesOptimization extends SceneOptimization {
  68548. private static _UpdateSelectionTree;
  68549. /**
  68550. * Gets or sets a boolean which defines if optimization octree has to be updated
  68551. */
  68552. static get UpdateSelectionTree(): boolean;
  68553. /**
  68554. * Gets or sets a boolean which defines if optimization octree has to be updated
  68555. */
  68556. static set UpdateSelectionTree(value: boolean);
  68557. /**
  68558. * Gets a string describing the action executed by the current optimization
  68559. * @return description string
  68560. */
  68561. getDescription(): string;
  68562. private _canBeMerged;
  68563. /**
  68564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68565. * @param scene defines the current scene where to apply this optimization
  68566. * @param optimizer defines the current optimizer
  68567. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68568. * @returns true if everything that can be done was applied
  68569. */
  68570. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68571. }
  68572. /**
  68573. * Defines a list of options used by SceneOptimizer
  68574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68575. */
  68576. export class SceneOptimizerOptions {
  68577. /**
  68578. * Defines the target frame rate to reach (60 by default)
  68579. */
  68580. targetFrameRate: number;
  68581. /**
  68582. * Defines the interval between two checkes (2000ms by default)
  68583. */
  68584. trackerDuration: number;
  68585. /**
  68586. * Gets the list of optimizations to apply
  68587. */
  68588. optimizations: SceneOptimization[];
  68589. /**
  68590. * Creates a new list of options used by SceneOptimizer
  68591. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68592. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68593. */
  68594. constructor(
  68595. /**
  68596. * Defines the target frame rate to reach (60 by default)
  68597. */
  68598. targetFrameRate?: number,
  68599. /**
  68600. * Defines the interval between two checkes (2000ms by default)
  68601. */
  68602. trackerDuration?: number);
  68603. /**
  68604. * Add a new optimization
  68605. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68606. * @returns the current SceneOptimizerOptions
  68607. */
  68608. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68609. /**
  68610. * Add a new custom optimization
  68611. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68612. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68613. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68614. * @returns the current SceneOptimizerOptions
  68615. */
  68616. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68617. /**
  68618. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68619. * @param targetFrameRate defines the target frame rate (60 by default)
  68620. * @returns a SceneOptimizerOptions object
  68621. */
  68622. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68623. /**
  68624. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68625. * @param targetFrameRate defines the target frame rate (60 by default)
  68626. * @returns a SceneOptimizerOptions object
  68627. */
  68628. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68629. /**
  68630. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68631. * @param targetFrameRate defines the target frame rate (60 by default)
  68632. * @returns a SceneOptimizerOptions object
  68633. */
  68634. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68635. }
  68636. /**
  68637. * Class used to run optimizations in order to reach a target frame rate
  68638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68639. */
  68640. export class SceneOptimizer implements IDisposable {
  68641. private _isRunning;
  68642. private _options;
  68643. private _scene;
  68644. private _currentPriorityLevel;
  68645. private _targetFrameRate;
  68646. private _trackerDuration;
  68647. private _currentFrameRate;
  68648. private _sceneDisposeObserver;
  68649. private _improvementMode;
  68650. /**
  68651. * Defines an observable called when the optimizer reaches the target frame rate
  68652. */
  68653. onSuccessObservable: Observable<SceneOptimizer>;
  68654. /**
  68655. * Defines an observable called when the optimizer enables an optimization
  68656. */
  68657. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68658. /**
  68659. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68660. */
  68661. onFailureObservable: Observable<SceneOptimizer>;
  68662. /**
  68663. * Gets a boolean indicating if the optimizer is in improvement mode
  68664. */
  68665. get isInImprovementMode(): boolean;
  68666. /**
  68667. * Gets the current priority level (0 at start)
  68668. */
  68669. get currentPriorityLevel(): number;
  68670. /**
  68671. * Gets the current frame rate checked by the SceneOptimizer
  68672. */
  68673. get currentFrameRate(): number;
  68674. /**
  68675. * Gets or sets the current target frame rate (60 by default)
  68676. */
  68677. get targetFrameRate(): number;
  68678. /**
  68679. * Gets or sets the current target frame rate (60 by default)
  68680. */
  68681. set targetFrameRate(value: number);
  68682. /**
  68683. * Gets or sets the current interval between two checks (every 2000ms by default)
  68684. */
  68685. get trackerDuration(): number;
  68686. /**
  68687. * Gets or sets the current interval between two checks (every 2000ms by default)
  68688. */
  68689. set trackerDuration(value: number);
  68690. /**
  68691. * Gets the list of active optimizations
  68692. */
  68693. get optimizations(): SceneOptimization[];
  68694. /**
  68695. * Creates a new SceneOptimizer
  68696. * @param scene defines the scene to work on
  68697. * @param options defines the options to use with the SceneOptimizer
  68698. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68699. * @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)
  68700. */
  68701. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68702. /**
  68703. * Stops the current optimizer
  68704. */
  68705. stop(): void;
  68706. /**
  68707. * Reset the optimizer to initial step (current priority level = 0)
  68708. */
  68709. reset(): void;
  68710. /**
  68711. * Start the optimizer. By default it will try to reach a specific framerate
  68712. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68713. */
  68714. start(): void;
  68715. private _checkCurrentState;
  68716. /**
  68717. * Release all resources
  68718. */
  68719. dispose(): void;
  68720. /**
  68721. * Helper function to create a SceneOptimizer with one single line of code
  68722. * @param scene defines the scene to work on
  68723. * @param options defines the options to use with the SceneOptimizer
  68724. * @param onSuccess defines a callback to call on success
  68725. * @param onFailure defines a callback to call on failure
  68726. * @returns the new SceneOptimizer object
  68727. */
  68728. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68729. }
  68730. }
  68731. declare module BABYLON {
  68732. /**
  68733. * Class used to serialize a scene into a string
  68734. */
  68735. export class SceneSerializer {
  68736. /**
  68737. * Clear cache used by a previous serialization
  68738. */
  68739. static ClearCache(): void;
  68740. /**
  68741. * Serialize a scene into a JSON compatible object
  68742. * @param scene defines the scene to serialize
  68743. * @returns a JSON compatible object
  68744. */
  68745. static Serialize(scene: Scene): any;
  68746. /**
  68747. * Serialize a mesh into a JSON compatible object
  68748. * @param toSerialize defines the mesh to serialize
  68749. * @param withParents defines if parents must be serialized as well
  68750. * @param withChildren defines if children must be serialized as well
  68751. * @returns a JSON compatible object
  68752. */
  68753. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68754. }
  68755. }
  68756. declare module BABYLON {
  68757. /**
  68758. * Class used to host texture specific utilities
  68759. */
  68760. export class TextureTools {
  68761. /**
  68762. * Uses the GPU to create a copy texture rescaled at a given size
  68763. * @param texture Texture to copy from
  68764. * @param width defines the desired width
  68765. * @param height defines the desired height
  68766. * @param useBilinearMode defines if bilinear mode has to be used
  68767. * @return the generated texture
  68768. */
  68769. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68770. }
  68771. }
  68772. declare module BABYLON {
  68773. /**
  68774. * This represents the different options available for the video capture.
  68775. */
  68776. export interface VideoRecorderOptions {
  68777. /** Defines the mime type of the video. */
  68778. mimeType: string;
  68779. /** Defines the FPS the video should be recorded at. */
  68780. fps: number;
  68781. /** Defines the chunk size for the recording data. */
  68782. recordChunckSize: number;
  68783. /** The audio tracks to attach to the recording. */
  68784. audioTracks?: MediaStreamTrack[];
  68785. }
  68786. /**
  68787. * This can help with recording videos from BabylonJS.
  68788. * This is based on the available WebRTC functionalities of the browser.
  68789. *
  68790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68791. */
  68792. export class VideoRecorder {
  68793. private static readonly _defaultOptions;
  68794. /**
  68795. * Returns whether or not the VideoRecorder is available in your browser.
  68796. * @param engine Defines the Babylon Engine.
  68797. * @returns true if supported otherwise false.
  68798. */
  68799. static IsSupported(engine: Engine): boolean;
  68800. private readonly _options;
  68801. private _canvas;
  68802. private _mediaRecorder;
  68803. private _recordedChunks;
  68804. private _fileName;
  68805. private _resolve;
  68806. private _reject;
  68807. /**
  68808. * True when a recording is already in progress.
  68809. */
  68810. get isRecording(): boolean;
  68811. /**
  68812. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68813. * @param engine Defines the BabylonJS Engine you wish to record.
  68814. * @param options Defines options that can be used to customize the capture.
  68815. */
  68816. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68817. /**
  68818. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68819. */
  68820. stopRecording(): void;
  68821. /**
  68822. * Starts recording the canvas for a max duration specified in parameters.
  68823. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68824. * If null no automatic download will start and you can rely on the promise to get the data back.
  68825. * @param maxDuration Defines the maximum recording time in seconds.
  68826. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68827. * @return A promise callback at the end of the recording with the video data in Blob.
  68828. */
  68829. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68830. /**
  68831. * Releases internal resources used during the recording.
  68832. */
  68833. dispose(): void;
  68834. private _handleDataAvailable;
  68835. private _handleError;
  68836. private _handleStop;
  68837. }
  68838. }
  68839. declare module BABYLON {
  68840. /**
  68841. * Class containing a set of static utilities functions for screenshots
  68842. */
  68843. export class ScreenshotTools {
  68844. /**
  68845. * Captures a screenshot of the current rendering
  68846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68847. * @param engine defines the rendering engine
  68848. * @param camera defines the source camera
  68849. * @param size This parameter can be set to a single number or to an object with the
  68850. * following (optional) properties: precision, width, height. If a single number is passed,
  68851. * it will be used for both width and height. If an object is passed, the screenshot size
  68852. * will be derived from the parameters. The precision property is a multiplier allowing
  68853. * rendering at a higher or lower resolution
  68854. * @param successCallback defines the callback receives a single parameter which contains the
  68855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68856. * src parameter of an <img> to display it
  68857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68858. * Check your browser for supported MIME types
  68859. */
  68860. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68861. /**
  68862. * Captures a screenshot of the current rendering
  68863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68864. * @param engine defines the rendering engine
  68865. * @param camera defines the source camera
  68866. * @param size This parameter can be set to a single number or to an object with the
  68867. * following (optional) properties: precision, width, height. If a single number is passed,
  68868. * it will be used for both width and height. If an object is passed, the screenshot size
  68869. * will be derived from the parameters. The precision property is a multiplier allowing
  68870. * rendering at a higher or lower resolution
  68871. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68872. * Check your browser for supported MIME types
  68873. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68874. * to the src parameter of an <img> to display it
  68875. */
  68876. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68877. /**
  68878. * Generates an image screenshot from the specified camera.
  68879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68880. * @param engine The engine to use for rendering
  68881. * @param camera The camera to use for rendering
  68882. * @param size This parameter can be set to a single number or to an object with the
  68883. * following (optional) properties: precision, width, height. If a single number is passed,
  68884. * it will be used for both width and height. If an object is passed, the screenshot size
  68885. * will be derived from the parameters. The precision property is a multiplier allowing
  68886. * rendering at a higher or lower resolution
  68887. * @param successCallback The callback receives a single parameter which contains the
  68888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68889. * src parameter of an <img> to display it
  68890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68891. * Check your browser for supported MIME types
  68892. * @param samples Texture samples (default: 1)
  68893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68894. * @param fileName A name for for the downloaded file.
  68895. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68896. */
  68897. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68898. /**
  68899. * Generates an image screenshot from the specified camera.
  68900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68901. * @param engine The engine to use for rendering
  68902. * @param camera The camera to use for rendering
  68903. * @param size This parameter can be set to a single number or to an object with the
  68904. * following (optional) properties: precision, width, height. If a single number is passed,
  68905. * it will be used for both width and height. If an object is passed, the screenshot size
  68906. * will be derived from the parameters. The precision property is a multiplier allowing
  68907. * rendering at a higher or lower resolution
  68908. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68909. * Check your browser for supported MIME types
  68910. * @param samples Texture samples (default: 1)
  68911. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68912. * @param fileName A name for for the downloaded file.
  68913. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68914. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68915. * to the src parameter of an <img> to display it
  68916. */
  68917. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68918. /**
  68919. * Gets height and width for screenshot size
  68920. * @private
  68921. */
  68922. private static _getScreenshotSize;
  68923. }
  68924. }
  68925. declare module BABYLON {
  68926. /**
  68927. * Interface for a data buffer
  68928. */
  68929. export interface IDataBuffer {
  68930. /**
  68931. * Reads bytes from the data buffer.
  68932. * @param byteOffset The byte offset to read
  68933. * @param byteLength The byte length to read
  68934. * @returns A promise that resolves when the bytes are read
  68935. */
  68936. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68937. /**
  68938. * The byte length of the buffer.
  68939. */
  68940. readonly byteLength: number;
  68941. }
  68942. /**
  68943. * Utility class for reading from a data buffer
  68944. */
  68945. export class DataReader {
  68946. /**
  68947. * The data buffer associated with this data reader.
  68948. */
  68949. readonly buffer: IDataBuffer;
  68950. /**
  68951. * The current byte offset from the beginning of the data buffer.
  68952. */
  68953. byteOffset: number;
  68954. private _dataView;
  68955. private _dataByteOffset;
  68956. /**
  68957. * Constructor
  68958. * @param buffer The buffer to read
  68959. */
  68960. constructor(buffer: IDataBuffer);
  68961. /**
  68962. * Loads the given byte length.
  68963. * @param byteLength The byte length to load
  68964. * @returns A promise that resolves when the load is complete
  68965. */
  68966. loadAsync(byteLength: number): Promise<void>;
  68967. /**
  68968. * Read a unsigned 32-bit integer from the currently loaded data range.
  68969. * @returns The 32-bit integer read
  68970. */
  68971. readUint32(): number;
  68972. /**
  68973. * Read a byte array from the currently loaded data range.
  68974. * @param byteLength The byte length to read
  68975. * @returns The byte array read
  68976. */
  68977. readUint8Array(byteLength: number): Uint8Array;
  68978. /**
  68979. * Read a string from the currently loaded data range.
  68980. * @param byteLength The byte length to read
  68981. * @returns The string read
  68982. */
  68983. readString(byteLength: number): string;
  68984. /**
  68985. * Skips the given byte length the currently loaded data range.
  68986. * @param byteLength The byte length to skip
  68987. */
  68988. skipBytes(byteLength: number): void;
  68989. }
  68990. }
  68991. declare module BABYLON {
  68992. /**
  68993. * Class for storing data to local storage if available or in-memory storage otherwise
  68994. */
  68995. export class DataStorage {
  68996. private static _Storage;
  68997. private static _GetStorage;
  68998. /**
  68999. * Reads a string from the data storage
  69000. * @param key The key to read
  69001. * @param defaultValue The value if the key doesn't exist
  69002. * @returns The string value
  69003. */
  69004. static ReadString(key: string, defaultValue: string): string;
  69005. /**
  69006. * Writes a string to the data storage
  69007. * @param key The key to write
  69008. * @param value The value to write
  69009. */
  69010. static WriteString(key: string, value: string): void;
  69011. /**
  69012. * Reads a boolean from the data storage
  69013. * @param key The key to read
  69014. * @param defaultValue The value if the key doesn't exist
  69015. * @returns The boolean value
  69016. */
  69017. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69018. /**
  69019. * Writes a boolean to the data storage
  69020. * @param key The key to write
  69021. * @param value The value to write
  69022. */
  69023. static WriteBoolean(key: string, value: boolean): void;
  69024. /**
  69025. * Reads a number from the data storage
  69026. * @param key The key to read
  69027. * @param defaultValue The value if the key doesn't exist
  69028. * @returns The number value
  69029. */
  69030. static ReadNumber(key: string, defaultValue: number): number;
  69031. /**
  69032. * Writes a number to the data storage
  69033. * @param key The key to write
  69034. * @param value The value to write
  69035. */
  69036. static WriteNumber(key: string, value: number): void;
  69037. }
  69038. }
  69039. declare module BABYLON {
  69040. /**
  69041. * Options used for hit testing
  69042. */
  69043. export interface IWebXRHitTestOptions {
  69044. /**
  69045. * Only test when user interacted with the scene. Default - hit test every frame
  69046. */
  69047. testOnPointerDownOnly?: boolean;
  69048. /**
  69049. * The node to use to transform the local results to world coordinates
  69050. */
  69051. worldParentNode?: TransformNode;
  69052. }
  69053. /**
  69054. * Interface defining the babylon result of raycasting/hit-test
  69055. */
  69056. export interface IWebXRHitResult {
  69057. /**
  69058. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69059. */
  69060. transformationMatrix: Matrix;
  69061. /**
  69062. * The native hit test result
  69063. */
  69064. xrHitResult: XRHitResult;
  69065. }
  69066. /**
  69067. * The currently-working hit-test module.
  69068. * Hit test (or Ray-casting) is used to interact with the real world.
  69069. * For further information read here - https://github.com/immersive-web/hit-test
  69070. */
  69071. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69072. /**
  69073. * options to use when constructing this feature
  69074. */
  69075. readonly options: IWebXRHitTestOptions;
  69076. private _direction;
  69077. private _mat;
  69078. private _onSelectEnabled;
  69079. private _origin;
  69080. /**
  69081. * The module's name
  69082. */
  69083. static readonly Name: string;
  69084. /**
  69085. * The (Babylon) version of this module.
  69086. * This is an integer representing the implementation version.
  69087. * This number does not correspond to the WebXR specs version
  69088. */
  69089. static readonly Version: number;
  69090. /**
  69091. * Populated with the last native XR Hit Results
  69092. */
  69093. lastNativeXRHitResults: XRHitResult[];
  69094. /**
  69095. * Triggered when new babylon (transformed) hit test results are available
  69096. */
  69097. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  69098. /**
  69099. * Creates a new instance of the (legacy version) hit test feature
  69100. * @param _xrSessionManager an instance of WebXRSessionManager
  69101. * @param options options to use when constructing this feature
  69102. */
  69103. constructor(_xrSessionManager: WebXRSessionManager,
  69104. /**
  69105. * options to use when constructing this feature
  69106. */
  69107. options?: IWebXRHitTestOptions);
  69108. /**
  69109. * execute a hit test with an XR Ray
  69110. *
  69111. * @param xrSession a native xrSession that will execute this hit test
  69112. * @param xrRay the ray (position and direction) to use for ray-casting
  69113. * @param referenceSpace native XR reference space to use for the hit-test
  69114. * @param filter filter function that will filter the results
  69115. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69116. */
  69117. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69118. /**
  69119. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69120. * @param event the (select) event to use to select with
  69121. * @param referenceSpace the reference space to use for this hit test
  69122. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69123. */
  69124. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69125. /**
  69126. * attach this feature
  69127. * Will usually be called by the features manager
  69128. *
  69129. * @returns true if successful.
  69130. */
  69131. attach(): boolean;
  69132. /**
  69133. * detach this feature.
  69134. * Will usually be called by the features manager
  69135. *
  69136. * @returns true if successful.
  69137. */
  69138. detach(): boolean;
  69139. /**
  69140. * Dispose this feature and all of the resources attached
  69141. */
  69142. dispose(): void;
  69143. protected _onXRFrame(frame: XRFrame): void;
  69144. private _onHitTestResults;
  69145. private _onSelect;
  69146. }
  69147. }
  69148. declare module BABYLON {
  69149. /**
  69150. * Options used in the plane detector module
  69151. */
  69152. export interface IWebXRPlaneDetectorOptions {
  69153. /**
  69154. * The node to use to transform the local results to world coordinates
  69155. */
  69156. worldParentNode?: TransformNode;
  69157. }
  69158. /**
  69159. * A babylon interface for a WebXR plane.
  69160. * A Plane is actually a polygon, built from N points in space
  69161. *
  69162. * Supported in chrome 79, not supported in canary 81 ATM
  69163. */
  69164. export interface IWebXRPlane {
  69165. /**
  69166. * a babylon-assigned ID for this polygon
  69167. */
  69168. id: number;
  69169. /**
  69170. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69171. */
  69172. polygonDefinition: Array<Vector3>;
  69173. /**
  69174. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69175. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69176. */
  69177. transformationMatrix: Matrix;
  69178. /**
  69179. * the native xr-plane object
  69180. */
  69181. xrPlane: XRPlane;
  69182. }
  69183. /**
  69184. * The plane detector is used to detect planes in the real world when in AR
  69185. * For more information see https://github.com/immersive-web/real-world-geometry/
  69186. */
  69187. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69188. private _options;
  69189. private _detectedPlanes;
  69190. private _enabled;
  69191. private _lastFrameDetected;
  69192. /**
  69193. * The module's name
  69194. */
  69195. static readonly Name: string;
  69196. /**
  69197. * The (Babylon) version of this module.
  69198. * This is an integer representing the implementation version.
  69199. * This number does not correspond to the WebXR specs version
  69200. */
  69201. static readonly Version: number;
  69202. /**
  69203. * Observers registered here will be executed when a new plane was added to the session
  69204. */
  69205. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69206. /**
  69207. * Observers registered here will be executed when a plane is no longer detected in the session
  69208. */
  69209. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69210. /**
  69211. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69212. * This can execute N times every frame
  69213. */
  69214. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69215. /**
  69216. * construct a new Plane Detector
  69217. * @param _xrSessionManager an instance of xr Session manager
  69218. * @param _options configuration to use when constructing this feature
  69219. */
  69220. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69221. /**
  69222. * Dispose this feature and all of the resources attached
  69223. */
  69224. dispose(): void;
  69225. protected _onXRFrame(frame: XRFrame): void;
  69226. private _init;
  69227. private _updatePlaneWithXRPlane;
  69228. /**
  69229. * avoiding using Array.find for global support.
  69230. * @param xrPlane the plane to find in the array
  69231. */
  69232. private findIndexInPlaneArray;
  69233. }
  69234. }
  69235. declare module BABYLON {
  69236. /**
  69237. * Configuration options of the anchor system
  69238. */
  69239. export interface IWebXRAnchorSystemOptions {
  69240. /**
  69241. * Should a new anchor be added every time a select event is triggered
  69242. */
  69243. addAnchorOnSelect?: boolean;
  69244. /**
  69245. * should the anchor system use plane detection.
  69246. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69247. */
  69248. usePlaneDetection?: boolean;
  69249. /**
  69250. * a node that will be used to convert local to world coordinates
  69251. */
  69252. worldParentNode?: TransformNode;
  69253. }
  69254. /**
  69255. * A babylon container for an XR Anchor
  69256. */
  69257. export interface IWebXRAnchor {
  69258. /**
  69259. * A babylon-assigned ID for this anchor
  69260. */
  69261. id: number;
  69262. /**
  69263. * Transformation matrix to apply to an object attached to this anchor
  69264. */
  69265. transformationMatrix: Matrix;
  69266. /**
  69267. * The native anchor object
  69268. */
  69269. xrAnchor: XRAnchor;
  69270. }
  69271. /**
  69272. * An implementation of the anchor system of WebXR.
  69273. * Note that the current documented implementation is not available in any browser. Future implementations
  69274. * will use the frame to create an anchor and not the session or a detected plane
  69275. * For further information see https://github.com/immersive-web/anchors/
  69276. */
  69277. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69278. private _options;
  69279. private _enabled;
  69280. private _hitTestModule;
  69281. private _lastFrameDetected;
  69282. private _onSelect;
  69283. private _planeDetector;
  69284. private _trackedAnchors;
  69285. /**
  69286. * The module's name
  69287. */
  69288. static readonly Name: string;
  69289. /**
  69290. * The (Babylon) version of this module.
  69291. * This is an integer representing the implementation version.
  69292. * This number does not correspond to the WebXR specs version
  69293. */
  69294. static readonly Version: number;
  69295. /**
  69296. * Observers registered here will be executed when a new anchor was added to the session
  69297. */
  69298. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69299. /**
  69300. * Observers registered here will be executed when an anchor was removed from the session
  69301. */
  69302. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69303. /**
  69304. * Observers registered here will be executed when an existing anchor updates
  69305. * This can execute N times every frame
  69306. */
  69307. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69308. /**
  69309. * constructs a new anchor system
  69310. * @param _xrSessionManager an instance of WebXRSessionManager
  69311. * @param _options configuration object for this feature
  69312. */
  69313. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69314. /**
  69315. * Add anchor at a specific XR point.
  69316. *
  69317. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69318. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69319. * @returns a promise the fulfills when the anchor was created
  69320. */
  69321. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69322. /**
  69323. * attach this feature
  69324. * Will usually be called by the features manager
  69325. *
  69326. * @returns true if successful.
  69327. */
  69328. attach(): boolean;
  69329. /**
  69330. * detach this feature.
  69331. * Will usually be called by the features manager
  69332. *
  69333. * @returns true if successful.
  69334. */
  69335. detach(): boolean;
  69336. /**
  69337. * Dispose this feature and all of the resources attached
  69338. */
  69339. dispose(): void;
  69340. /**
  69341. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69342. * @param hitTestModule the hit-test module to use.
  69343. */
  69344. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69345. /**
  69346. * set the plane detector to use in order to create anchors from frames
  69347. * @param planeDetector the plane-detector module to use
  69348. * @param enable enable plane-anchors. default is true
  69349. */
  69350. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69351. protected _onXRFrame(frame: XRFrame): void;
  69352. /**
  69353. * avoiding using Array.find for global support.
  69354. * @param xrAnchor the plane to find in the array
  69355. */
  69356. private _findIndexInAnchorArray;
  69357. private _updateAnchorWithXRFrame;
  69358. }
  69359. }
  69360. declare module BABYLON {
  69361. /**
  69362. * Options interface for the background remover plugin
  69363. */
  69364. export interface IWebXRBackgroundRemoverOptions {
  69365. /**
  69366. * Further background meshes to disable when entering AR
  69367. */
  69368. backgroundMeshes?: AbstractMesh[];
  69369. /**
  69370. * flags to configure the removal of the environment helper.
  69371. * If not set, the entire background will be removed. If set, flags should be set as well.
  69372. */
  69373. environmentHelperRemovalFlags?: {
  69374. /**
  69375. * Should the skybox be removed (default false)
  69376. */
  69377. skyBox?: boolean;
  69378. /**
  69379. * Should the ground be removed (default false)
  69380. */
  69381. ground?: boolean;
  69382. };
  69383. /**
  69384. * don't disable the environment helper
  69385. */
  69386. ignoreEnvironmentHelper?: boolean;
  69387. }
  69388. /**
  69389. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69390. */
  69391. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69392. /**
  69393. * read-only options to be used in this module
  69394. */
  69395. readonly options: IWebXRBackgroundRemoverOptions;
  69396. /**
  69397. * The module's name
  69398. */
  69399. static readonly Name: string;
  69400. /**
  69401. * The (Babylon) version of this module.
  69402. * This is an integer representing the implementation version.
  69403. * This number does not correspond to the WebXR specs version
  69404. */
  69405. static readonly Version: number;
  69406. /**
  69407. * registered observers will be triggered when the background state changes
  69408. */
  69409. onBackgroundStateChangedObservable: Observable<boolean>;
  69410. /**
  69411. * constructs a new background remover module
  69412. * @param _xrSessionManager the session manager for this module
  69413. * @param options read-only options to be used in this module
  69414. */
  69415. constructor(_xrSessionManager: WebXRSessionManager,
  69416. /**
  69417. * read-only options to be used in this module
  69418. */
  69419. options?: IWebXRBackgroundRemoverOptions);
  69420. /**
  69421. * attach this feature
  69422. * Will usually be called by the features manager
  69423. *
  69424. * @returns true if successful.
  69425. */
  69426. attach(): boolean;
  69427. /**
  69428. * detach this feature.
  69429. * Will usually be called by the features manager
  69430. *
  69431. * @returns true if successful.
  69432. */
  69433. detach(): boolean;
  69434. /**
  69435. * Dispose this feature and all of the resources attached
  69436. */
  69437. dispose(): void;
  69438. protected _onXRFrame(_xrFrame: XRFrame): void;
  69439. private _setBackgroundState;
  69440. }
  69441. }
  69442. declare module BABYLON {
  69443. /**
  69444. * Options for the controller physics feature
  69445. */
  69446. export class IWebXRControllerPhysicsOptions {
  69447. /**
  69448. * Should the headset get its own impostor
  69449. */
  69450. enableHeadsetImpostor?: boolean;
  69451. /**
  69452. * Optional parameters for the headset impostor
  69453. */
  69454. headsetImpostorParams?: {
  69455. /**
  69456. * The type of impostor to create. Default is sphere
  69457. */
  69458. impostorType: number;
  69459. /**
  69460. * the size of the impostor. Defaults to 10cm
  69461. */
  69462. impostorSize?: number | {
  69463. width: number;
  69464. height: number;
  69465. depth: number;
  69466. };
  69467. /**
  69468. * Friction definitions
  69469. */
  69470. friction?: number;
  69471. /**
  69472. * Restitution
  69473. */
  69474. restitution?: number;
  69475. };
  69476. /**
  69477. * The physics properties of the future impostors
  69478. */
  69479. physicsProperties?: {
  69480. /**
  69481. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69482. * Note that this requires a physics engine that supports mesh impostors!
  69483. */
  69484. useControllerMesh?: boolean;
  69485. /**
  69486. * The type of impostor to create. Default is sphere
  69487. */
  69488. impostorType?: number;
  69489. /**
  69490. * the size of the impostor. Defaults to 10cm
  69491. */
  69492. impostorSize?: number | {
  69493. width: number;
  69494. height: number;
  69495. depth: number;
  69496. };
  69497. /**
  69498. * Friction definitions
  69499. */
  69500. friction?: number;
  69501. /**
  69502. * Restitution
  69503. */
  69504. restitution?: number;
  69505. };
  69506. /**
  69507. * the xr input to use with this pointer selection
  69508. */
  69509. xrInput: WebXRInput;
  69510. }
  69511. /**
  69512. * Add physics impostor to your webxr controllers,
  69513. * including naive calculation of their linear and angular velocity
  69514. */
  69515. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69516. private readonly _options;
  69517. private _attachController;
  69518. private _controllers;
  69519. private _debugMode;
  69520. private _delta;
  69521. private _headsetImpostor?;
  69522. private _headsetMesh?;
  69523. private _lastTimestamp;
  69524. private _tmpQuaternion;
  69525. private _tmpVector;
  69526. /**
  69527. * The module's name
  69528. */
  69529. static readonly Name: string;
  69530. /**
  69531. * The (Babylon) version of this module.
  69532. * This is an integer representing the implementation version.
  69533. * This number does not correspond to the webxr specs version
  69534. */
  69535. static readonly Version: number;
  69536. /**
  69537. * Construct a new Controller Physics Feature
  69538. * @param _xrSessionManager the corresponding xr session manager
  69539. * @param _options options to create this feature with
  69540. */
  69541. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69542. /**
  69543. * @hidden
  69544. * enable debugging - will show console outputs and the impostor mesh
  69545. */
  69546. _enablePhysicsDebug(): void;
  69547. /**
  69548. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69549. * @param xrController the controller to add
  69550. */
  69551. addController(xrController: WebXRInputSource): void;
  69552. /**
  69553. * attach this feature
  69554. * Will usually be called by the features manager
  69555. *
  69556. * @returns true if successful.
  69557. */
  69558. attach(): boolean;
  69559. /**
  69560. * detach this feature.
  69561. * Will usually be called by the features manager
  69562. *
  69563. * @returns true if successful.
  69564. */
  69565. detach(): boolean;
  69566. /**
  69567. * Get the headset impostor, if enabled
  69568. * @returns the impostor
  69569. */
  69570. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69571. /**
  69572. * Get the physics impostor of a specific controller.
  69573. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69574. * @param controller the controller or the controller id of which to get the impostor
  69575. * @returns the impostor or null
  69576. */
  69577. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69578. /**
  69579. * Update the physics properties provided in the constructor
  69580. * @param newProperties the new properties object
  69581. */
  69582. setPhysicsProperties(newProperties: {
  69583. impostorType?: number;
  69584. impostorSize?: number | {
  69585. width: number;
  69586. height: number;
  69587. depth: number;
  69588. };
  69589. friction?: number;
  69590. restitution?: number;
  69591. }): void;
  69592. protected _onXRFrame(_xrFrame: any): void;
  69593. private _detachController;
  69594. }
  69595. }
  69596. declare module BABYLON {
  69597. /**
  69598. * The motion controller class for all microsoft mixed reality controllers
  69599. */
  69600. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69601. protected readonly _mapping: {
  69602. defaultButton: {
  69603. "valueNodeName": string;
  69604. "unpressedNodeName": string;
  69605. "pressedNodeName": string;
  69606. };
  69607. defaultAxis: {
  69608. "valueNodeName": string;
  69609. "minNodeName": string;
  69610. "maxNodeName": string;
  69611. };
  69612. buttons: {
  69613. "xr-standard-trigger": {
  69614. "rootNodeName": string;
  69615. "componentProperty": string;
  69616. "states": string[];
  69617. };
  69618. "xr-standard-squeeze": {
  69619. "rootNodeName": string;
  69620. "componentProperty": string;
  69621. "states": string[];
  69622. };
  69623. "xr-standard-touchpad": {
  69624. "rootNodeName": string;
  69625. "labelAnchorNodeName": string;
  69626. "touchPointNodeName": string;
  69627. };
  69628. "xr-standard-thumbstick": {
  69629. "rootNodeName": string;
  69630. "componentProperty": string;
  69631. "states": string[];
  69632. };
  69633. };
  69634. axes: {
  69635. "xr-standard-touchpad": {
  69636. "x-axis": {
  69637. "rootNodeName": string;
  69638. };
  69639. "y-axis": {
  69640. "rootNodeName": string;
  69641. };
  69642. };
  69643. "xr-standard-thumbstick": {
  69644. "x-axis": {
  69645. "rootNodeName": string;
  69646. };
  69647. "y-axis": {
  69648. "rootNodeName": string;
  69649. };
  69650. };
  69651. };
  69652. };
  69653. /**
  69654. * The base url used to load the left and right controller models
  69655. */
  69656. static MODEL_BASE_URL: string;
  69657. /**
  69658. * The name of the left controller model file
  69659. */
  69660. static MODEL_LEFT_FILENAME: string;
  69661. /**
  69662. * The name of the right controller model file
  69663. */
  69664. static MODEL_RIGHT_FILENAME: string;
  69665. profileId: string;
  69666. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69667. protected _getFilenameAndPath(): {
  69668. filename: string;
  69669. path: string;
  69670. };
  69671. protected _getModelLoadingConstraints(): boolean;
  69672. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69673. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69674. protected _updateModel(): void;
  69675. }
  69676. }
  69677. declare module BABYLON {
  69678. /**
  69679. * The motion controller class for oculus touch (quest, rift).
  69680. * This class supports legacy mapping as well the standard xr mapping
  69681. */
  69682. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69683. private _forceLegacyControllers;
  69684. private _modelRootNode;
  69685. /**
  69686. * The base url used to load the left and right controller models
  69687. */
  69688. static MODEL_BASE_URL: string;
  69689. /**
  69690. * The name of the left controller model file
  69691. */
  69692. static MODEL_LEFT_FILENAME: string;
  69693. /**
  69694. * The name of the right controller model file
  69695. */
  69696. static MODEL_RIGHT_FILENAME: string;
  69697. /**
  69698. * Base Url for the Quest controller model.
  69699. */
  69700. static QUEST_MODEL_BASE_URL: string;
  69701. profileId: string;
  69702. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69703. protected _getFilenameAndPath(): {
  69704. filename: string;
  69705. path: string;
  69706. };
  69707. protected _getModelLoadingConstraints(): boolean;
  69708. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69709. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69710. protected _updateModel(): void;
  69711. /**
  69712. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69713. * between the touch and touch 2.
  69714. */
  69715. private _isQuest;
  69716. }
  69717. }
  69718. declare module BABYLON {
  69719. /**
  69720. * The motion controller class for the standard HTC-Vive controllers
  69721. */
  69722. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69723. private _modelRootNode;
  69724. /**
  69725. * The base url used to load the left and right controller models
  69726. */
  69727. static MODEL_BASE_URL: string;
  69728. /**
  69729. * File name for the controller model.
  69730. */
  69731. static MODEL_FILENAME: string;
  69732. profileId: string;
  69733. /**
  69734. * Create a new Vive motion controller object
  69735. * @param scene the scene to use to create this controller
  69736. * @param gamepadObject the corresponding gamepad object
  69737. * @param handness the handness of the controller
  69738. */
  69739. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69740. protected _getFilenameAndPath(): {
  69741. filename: string;
  69742. path: string;
  69743. };
  69744. protected _getModelLoadingConstraints(): boolean;
  69745. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69746. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69747. protected _updateModel(): void;
  69748. }
  69749. }
  69750. declare module BABYLON {
  69751. /**
  69752. * A cursor which tracks a point on a path
  69753. */
  69754. export class PathCursor {
  69755. private path;
  69756. /**
  69757. * Stores path cursor callbacks for when an onchange event is triggered
  69758. */
  69759. private _onchange;
  69760. /**
  69761. * The value of the path cursor
  69762. */
  69763. value: number;
  69764. /**
  69765. * The animation array of the path cursor
  69766. */
  69767. animations: Animation[];
  69768. /**
  69769. * Initializes the path cursor
  69770. * @param path The path to track
  69771. */
  69772. constructor(path: Path2);
  69773. /**
  69774. * Gets the cursor point on the path
  69775. * @returns A point on the path cursor at the cursor location
  69776. */
  69777. getPoint(): Vector3;
  69778. /**
  69779. * Moves the cursor ahead by the step amount
  69780. * @param step The amount to move the cursor forward
  69781. * @returns This path cursor
  69782. */
  69783. moveAhead(step?: number): PathCursor;
  69784. /**
  69785. * Moves the cursor behind by the step amount
  69786. * @param step The amount to move the cursor back
  69787. * @returns This path cursor
  69788. */
  69789. moveBack(step?: number): PathCursor;
  69790. /**
  69791. * Moves the cursor by the step amount
  69792. * If the step amount is greater than one, an exception is thrown
  69793. * @param step The amount to move the cursor
  69794. * @returns This path cursor
  69795. */
  69796. move(step: number): PathCursor;
  69797. /**
  69798. * Ensures that the value is limited between zero and one
  69799. * @returns This path cursor
  69800. */
  69801. private ensureLimits;
  69802. /**
  69803. * Runs onchange callbacks on change (used by the animation engine)
  69804. * @returns This path cursor
  69805. */
  69806. private raiseOnChange;
  69807. /**
  69808. * Executes a function on change
  69809. * @param f A path cursor onchange callback
  69810. * @returns This path cursor
  69811. */
  69812. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69813. }
  69814. }
  69815. declare module BABYLON {
  69816. /** @hidden */
  69817. export var blurPixelShader: {
  69818. name: string;
  69819. shader: string;
  69820. };
  69821. }
  69822. declare module BABYLON {
  69823. /** @hidden */
  69824. export var pointCloudVertexDeclaration: {
  69825. name: string;
  69826. shader: string;
  69827. };
  69828. }
  69829. // Mixins
  69830. interface Window {
  69831. mozIndexedDB: IDBFactory;
  69832. webkitIndexedDB: IDBFactory;
  69833. msIndexedDB: IDBFactory;
  69834. webkitURL: typeof URL;
  69835. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69836. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69837. WebGLRenderingContext: WebGLRenderingContext;
  69838. MSGesture: MSGesture;
  69839. CANNON: any;
  69840. AudioContext: AudioContext;
  69841. webkitAudioContext: AudioContext;
  69842. PointerEvent: any;
  69843. Math: Math;
  69844. Uint8Array: Uint8ArrayConstructor;
  69845. Float32Array: Float32ArrayConstructor;
  69846. mozURL: typeof URL;
  69847. msURL: typeof URL;
  69848. VRFrameData: any; // WebVR, from specs 1.1
  69849. DracoDecoderModule: any;
  69850. setImmediate(handler: (...args: any[]) => void): number;
  69851. }
  69852. interface HTMLCanvasElement {
  69853. requestPointerLock(): void;
  69854. msRequestPointerLock?(): void;
  69855. mozRequestPointerLock?(): void;
  69856. webkitRequestPointerLock?(): void;
  69857. /** Track wether a record is in progress */
  69858. isRecording: boolean;
  69859. /** Capture Stream method defined by some browsers */
  69860. captureStream(fps?: number): MediaStream;
  69861. }
  69862. interface CanvasRenderingContext2D {
  69863. msImageSmoothingEnabled: boolean;
  69864. }
  69865. interface MouseEvent {
  69866. mozMovementX: number;
  69867. mozMovementY: number;
  69868. webkitMovementX: number;
  69869. webkitMovementY: number;
  69870. msMovementX: number;
  69871. msMovementY: number;
  69872. }
  69873. interface Navigator {
  69874. mozGetVRDevices: (any: any) => any;
  69875. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69876. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69877. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69878. webkitGetGamepads(): Gamepad[];
  69879. msGetGamepads(): Gamepad[];
  69880. webkitGamepads(): Gamepad[];
  69881. }
  69882. interface HTMLVideoElement {
  69883. mozSrcObject: any;
  69884. }
  69885. interface Math {
  69886. fround(x: number): number;
  69887. imul(a: number, b: number): number;
  69888. }
  69889. interface WebGLRenderingContext {
  69890. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69891. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69892. vertexAttribDivisor(index: number, divisor: number): void;
  69893. createVertexArray(): any;
  69894. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69895. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69896. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69897. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69898. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69899. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69900. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69901. // Queries
  69902. createQuery(): WebGLQuery;
  69903. deleteQuery(query: WebGLQuery): void;
  69904. beginQuery(target: number, query: WebGLQuery): void;
  69905. endQuery(target: number): void;
  69906. getQueryParameter(query: WebGLQuery, pname: number): any;
  69907. getQuery(target: number, pname: number): any;
  69908. MAX_SAMPLES: number;
  69909. RGBA8: number;
  69910. READ_FRAMEBUFFER: number;
  69911. DRAW_FRAMEBUFFER: number;
  69912. UNIFORM_BUFFER: number;
  69913. HALF_FLOAT_OES: number;
  69914. RGBA16F: number;
  69915. RGBA32F: number;
  69916. R32F: number;
  69917. RG32F: number;
  69918. RGB32F: number;
  69919. R16F: number;
  69920. RG16F: number;
  69921. RGB16F: number;
  69922. RED: number;
  69923. RG: number;
  69924. R8: number;
  69925. RG8: number;
  69926. UNSIGNED_INT_24_8: number;
  69927. DEPTH24_STENCIL8: number;
  69928. MIN: number;
  69929. MAX: number;
  69930. /* Multiple Render Targets */
  69931. drawBuffers(buffers: number[]): void;
  69932. readBuffer(src: number): void;
  69933. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69934. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69935. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69936. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69937. // Occlusion Query
  69938. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69939. ANY_SAMPLES_PASSED: number;
  69940. QUERY_RESULT_AVAILABLE: number;
  69941. QUERY_RESULT: number;
  69942. }
  69943. interface WebGLProgram {
  69944. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69945. }
  69946. interface EXT_disjoint_timer_query {
  69947. QUERY_COUNTER_BITS_EXT: number;
  69948. TIME_ELAPSED_EXT: number;
  69949. TIMESTAMP_EXT: number;
  69950. GPU_DISJOINT_EXT: number;
  69951. QUERY_RESULT_EXT: number;
  69952. QUERY_RESULT_AVAILABLE_EXT: number;
  69953. queryCounterEXT(query: WebGLQuery, target: number): void;
  69954. createQueryEXT(): WebGLQuery;
  69955. beginQueryEXT(target: number, query: WebGLQuery): void;
  69956. endQueryEXT(target: number): void;
  69957. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69958. deleteQueryEXT(query: WebGLQuery): void;
  69959. }
  69960. interface WebGLUniformLocation {
  69961. _currentState: any;
  69962. }
  69963. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69964. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69965. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69966. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69967. interface WebGLRenderingContext {
  69968. readonly RASTERIZER_DISCARD: number;
  69969. readonly DEPTH_COMPONENT24: number;
  69970. readonly TEXTURE_3D: number;
  69971. readonly TEXTURE_2D_ARRAY: number;
  69972. readonly TEXTURE_COMPARE_FUNC: number;
  69973. readonly TEXTURE_COMPARE_MODE: number;
  69974. readonly COMPARE_REF_TO_TEXTURE: number;
  69975. readonly TEXTURE_WRAP_R: number;
  69976. readonly HALF_FLOAT: number;
  69977. readonly RGB8: number;
  69978. readonly RED_INTEGER: number;
  69979. readonly RG_INTEGER: number;
  69980. readonly RGB_INTEGER: number;
  69981. readonly RGBA_INTEGER: number;
  69982. readonly R8_SNORM: number;
  69983. readonly RG8_SNORM: number;
  69984. readonly RGB8_SNORM: number;
  69985. readonly RGBA8_SNORM: number;
  69986. readonly R8I: number;
  69987. readonly RG8I: number;
  69988. readonly RGB8I: number;
  69989. readonly RGBA8I: number;
  69990. readonly R8UI: number;
  69991. readonly RG8UI: number;
  69992. readonly RGB8UI: number;
  69993. readonly RGBA8UI: number;
  69994. readonly R16I: number;
  69995. readonly RG16I: number;
  69996. readonly RGB16I: number;
  69997. readonly RGBA16I: number;
  69998. readonly R16UI: number;
  69999. readonly RG16UI: number;
  70000. readonly RGB16UI: number;
  70001. readonly RGBA16UI: number;
  70002. readonly R32I: number;
  70003. readonly RG32I: number;
  70004. readonly RGB32I: number;
  70005. readonly RGBA32I: number;
  70006. readonly R32UI: number;
  70007. readonly RG32UI: number;
  70008. readonly RGB32UI: number;
  70009. readonly RGBA32UI: number;
  70010. readonly RGB10_A2UI: number;
  70011. readonly R11F_G11F_B10F: number;
  70012. readonly RGB9_E5: number;
  70013. readonly RGB10_A2: number;
  70014. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70015. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70016. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70017. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70018. readonly DEPTH_COMPONENT32F: number;
  70019. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70020. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70021. 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;
  70022. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70023. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70024. readonly TRANSFORM_FEEDBACK: number;
  70025. readonly INTERLEAVED_ATTRIBS: number;
  70026. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70027. createTransformFeedback(): WebGLTransformFeedback;
  70028. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70029. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70030. beginTransformFeedback(primitiveMode: number): void;
  70031. endTransformFeedback(): void;
  70032. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70033. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70034. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70035. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70036. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70037. }
  70038. interface ImageBitmap {
  70039. readonly width: number;
  70040. readonly height: number;
  70041. close(): void;
  70042. }
  70043. interface WebGLQuery extends WebGLObject {
  70044. }
  70045. declare var WebGLQuery: {
  70046. prototype: WebGLQuery;
  70047. new(): WebGLQuery;
  70048. };
  70049. interface WebGLSampler extends WebGLObject {
  70050. }
  70051. declare var WebGLSampler: {
  70052. prototype: WebGLSampler;
  70053. new(): WebGLSampler;
  70054. };
  70055. interface WebGLSync extends WebGLObject {
  70056. }
  70057. declare var WebGLSync: {
  70058. prototype: WebGLSync;
  70059. new(): WebGLSync;
  70060. };
  70061. interface WebGLTransformFeedback extends WebGLObject {
  70062. }
  70063. declare var WebGLTransformFeedback: {
  70064. prototype: WebGLTransformFeedback;
  70065. new(): WebGLTransformFeedback;
  70066. };
  70067. interface WebGLVertexArrayObject extends WebGLObject {
  70068. }
  70069. declare var WebGLVertexArrayObject: {
  70070. prototype: WebGLVertexArrayObject;
  70071. new(): WebGLVertexArrayObject;
  70072. };
  70073. // Type definitions for WebVR API
  70074. // Project: https://w3c.github.io/webvr/
  70075. // Definitions by: six a <https://github.com/lostfictions>
  70076. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70077. interface VRDisplay extends EventTarget {
  70078. /**
  70079. * Dictionary of capabilities describing the VRDisplay.
  70080. */
  70081. readonly capabilities: VRDisplayCapabilities;
  70082. /**
  70083. * z-depth defining the far plane of the eye view frustum
  70084. * enables mapping of values in the render target depth
  70085. * attachment to scene coordinates. Initially set to 10000.0.
  70086. */
  70087. depthFar: number;
  70088. /**
  70089. * z-depth defining the near plane of the eye view frustum
  70090. * enables mapping of values in the render target depth
  70091. * attachment to scene coordinates. Initially set to 0.01.
  70092. */
  70093. depthNear: number;
  70094. /**
  70095. * An identifier for this distinct VRDisplay. Used as an
  70096. * association point in the Gamepad API.
  70097. */
  70098. readonly displayId: number;
  70099. /**
  70100. * A display name, a user-readable name identifying it.
  70101. */
  70102. readonly displayName: string;
  70103. readonly isConnected: boolean;
  70104. readonly isPresenting: boolean;
  70105. /**
  70106. * If this VRDisplay supports room-scale experiences, the optional
  70107. * stage attribute contains details on the room-scale parameters.
  70108. */
  70109. readonly stageParameters: VRStageParameters | null;
  70110. /**
  70111. * Passing the value returned by `requestAnimationFrame` to
  70112. * `cancelAnimationFrame` will unregister the callback.
  70113. * @param handle Define the hanle of the request to cancel
  70114. */
  70115. cancelAnimationFrame(handle: number): void;
  70116. /**
  70117. * Stops presenting to the VRDisplay.
  70118. * @returns a promise to know when it stopped
  70119. */
  70120. exitPresent(): Promise<void>;
  70121. /**
  70122. * Return the current VREyeParameters for the given eye.
  70123. * @param whichEye Define the eye we want the parameter for
  70124. * @returns the eye parameters
  70125. */
  70126. getEyeParameters(whichEye: string): VREyeParameters;
  70127. /**
  70128. * Populates the passed VRFrameData with the information required to render
  70129. * the current frame.
  70130. * @param frameData Define the data structure to populate
  70131. * @returns true if ok otherwise false
  70132. */
  70133. getFrameData(frameData: VRFrameData): boolean;
  70134. /**
  70135. * Get the layers currently being presented.
  70136. * @returns the list of VR layers
  70137. */
  70138. getLayers(): VRLayer[];
  70139. /**
  70140. * Return a VRPose containing the future predicted pose of the VRDisplay
  70141. * when the current frame will be presented. The value returned will not
  70142. * change until JavaScript has returned control to the browser.
  70143. *
  70144. * The VRPose will contain the position, orientation, velocity,
  70145. * and acceleration of each of these properties.
  70146. * @returns the pose object
  70147. */
  70148. getPose(): VRPose;
  70149. /**
  70150. * Return the current instantaneous pose of the VRDisplay, with no
  70151. * prediction applied.
  70152. * @returns the current instantaneous pose
  70153. */
  70154. getImmediatePose(): VRPose;
  70155. /**
  70156. * The callback passed to `requestAnimationFrame` will be called
  70157. * any time a new frame should be rendered. When the VRDisplay is
  70158. * presenting the callback will be called at the native refresh
  70159. * rate of the HMD. When not presenting this function acts
  70160. * identically to how window.requestAnimationFrame acts. Content should
  70161. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70162. * asynchronously from other displays and at differing refresh rates.
  70163. * @param callback Define the eaction to run next frame
  70164. * @returns the request handle it
  70165. */
  70166. requestAnimationFrame(callback: FrameRequestCallback): number;
  70167. /**
  70168. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70169. * Repeat calls while already presenting will update the VRLayers being displayed.
  70170. * @param layers Define the list of layer to present
  70171. * @returns a promise to know when the request has been fulfilled
  70172. */
  70173. requestPresent(layers: VRLayer[]): Promise<void>;
  70174. /**
  70175. * Reset the pose for this display, treating its current position and
  70176. * orientation as the "origin/zero" values. VRPose.position,
  70177. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70178. * updated when calling resetPose(). This should be called in only
  70179. * sitting-space experiences.
  70180. */
  70181. resetPose(): void;
  70182. /**
  70183. * The VRLayer provided to the VRDisplay will be captured and presented
  70184. * in the HMD. Calling this function has the same effect on the source
  70185. * canvas as any other operation that uses its source image, and canvases
  70186. * created without preserveDrawingBuffer set to true will be cleared.
  70187. * @param pose Define the pose to submit
  70188. */
  70189. submitFrame(pose?: VRPose): void;
  70190. }
  70191. declare var VRDisplay: {
  70192. prototype: VRDisplay;
  70193. new(): VRDisplay;
  70194. };
  70195. interface VRLayer {
  70196. leftBounds?: number[] | Float32Array | null;
  70197. rightBounds?: number[] | Float32Array | null;
  70198. source?: HTMLCanvasElement | null;
  70199. }
  70200. interface VRDisplayCapabilities {
  70201. readonly canPresent: boolean;
  70202. readonly hasExternalDisplay: boolean;
  70203. readonly hasOrientation: boolean;
  70204. readonly hasPosition: boolean;
  70205. readonly maxLayers: number;
  70206. }
  70207. interface VREyeParameters {
  70208. /** @deprecated */
  70209. readonly fieldOfView: VRFieldOfView;
  70210. readonly offset: Float32Array;
  70211. readonly renderHeight: number;
  70212. readonly renderWidth: number;
  70213. }
  70214. interface VRFieldOfView {
  70215. readonly downDegrees: number;
  70216. readonly leftDegrees: number;
  70217. readonly rightDegrees: number;
  70218. readonly upDegrees: number;
  70219. }
  70220. interface VRFrameData {
  70221. readonly leftProjectionMatrix: Float32Array;
  70222. readonly leftViewMatrix: Float32Array;
  70223. readonly pose: VRPose;
  70224. readonly rightProjectionMatrix: Float32Array;
  70225. readonly rightViewMatrix: Float32Array;
  70226. readonly timestamp: number;
  70227. }
  70228. interface VRPose {
  70229. readonly angularAcceleration: Float32Array | null;
  70230. readonly angularVelocity: Float32Array | null;
  70231. readonly linearAcceleration: Float32Array | null;
  70232. readonly linearVelocity: Float32Array | null;
  70233. readonly orientation: Float32Array | null;
  70234. readonly position: Float32Array | null;
  70235. readonly timestamp: number;
  70236. }
  70237. interface VRStageParameters {
  70238. sittingToStandingTransform?: Float32Array;
  70239. sizeX?: number;
  70240. sizeY?: number;
  70241. }
  70242. interface Navigator {
  70243. getVRDisplays(): Promise<VRDisplay[]>;
  70244. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70245. }
  70246. interface Window {
  70247. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70248. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70249. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70250. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70251. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70252. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70253. }
  70254. interface Gamepad {
  70255. readonly displayId: number;
  70256. }
  70257. type XRSessionMode =
  70258. | "inline"
  70259. | "immersive-vr"
  70260. | "immersive-ar";
  70261. type XRReferenceSpaceType =
  70262. | "viewer"
  70263. | "local"
  70264. | "local-floor"
  70265. | "bounded-floor"
  70266. | "unbounded";
  70267. type XREnvironmentBlendMode =
  70268. | "opaque"
  70269. | "additive"
  70270. | "alpha-blend";
  70271. type XRVisibilityState =
  70272. | "visible"
  70273. | "visible-blurred"
  70274. | "hidden";
  70275. type XRHandedness =
  70276. | "none"
  70277. | "left"
  70278. | "right";
  70279. type XRTargetRayMode =
  70280. | "gaze"
  70281. | "tracked-pointer"
  70282. | "screen";
  70283. type XREye =
  70284. | "none"
  70285. | "left"
  70286. | "right";
  70287. interface XRSpace extends EventTarget {
  70288. }
  70289. interface XRRenderState {
  70290. depthNear?: number;
  70291. depthFar?: number;
  70292. inlineVerticalFieldOfView?: number;
  70293. baseLayer?: XRWebGLLayer;
  70294. }
  70295. interface XRInputSource {
  70296. handedness: XRHandedness;
  70297. targetRayMode: XRTargetRayMode;
  70298. targetRaySpace: XRSpace;
  70299. gripSpace: XRSpace | undefined;
  70300. gamepad: Gamepad | undefined;
  70301. profiles: Array<string>;
  70302. }
  70303. interface XRSessionInit {
  70304. optionalFeatures?: XRReferenceSpaceType[];
  70305. requiredFeatures?: XRReferenceSpaceType[];
  70306. }
  70307. interface XRSession extends XRAnchorCreator {
  70308. addEventListener: Function;
  70309. removeEventListener: Function;
  70310. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70311. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70312. requestAnimationFrame: Function;
  70313. end(): Promise<void>;
  70314. renderState: XRRenderState;
  70315. inputSources: Array<XRInputSource>;
  70316. // AR hit test
  70317. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70318. updateWorldTrackingState(options: {
  70319. planeDetectionState?: { enabled: boolean; }
  70320. }): void;
  70321. }
  70322. interface XRReferenceSpace extends XRSpace {
  70323. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70324. onreset: any;
  70325. }
  70326. type XRPlaneSet = Set<XRPlane>;
  70327. type XRAnchorSet = Set<XRAnchor>;
  70328. interface XRFrame {
  70329. session: XRSession;
  70330. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70331. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70332. // Anchors
  70333. trackedAnchors?: XRAnchorSet;
  70334. // Planes
  70335. worldInformation: {
  70336. detectedPlanes?: XRPlaneSet;
  70337. };
  70338. }
  70339. interface XRViewerPose extends XRPose {
  70340. views: Array<XRView>;
  70341. }
  70342. interface XRPose {
  70343. transform: XRRigidTransform;
  70344. emulatedPosition: boolean;
  70345. }
  70346. interface XRWebGLLayerOptions {
  70347. antialias?: boolean;
  70348. depth?: boolean;
  70349. stencil?: boolean;
  70350. alpha?: boolean;
  70351. multiview?: boolean;
  70352. framebufferScaleFactor?: number;
  70353. }
  70354. declare var XRWebGLLayer: {
  70355. prototype: XRWebGLLayer;
  70356. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70357. };
  70358. interface XRWebGLLayer {
  70359. framebuffer: WebGLFramebuffer;
  70360. framebufferWidth: number;
  70361. framebufferHeight: number;
  70362. getViewport: Function;
  70363. }
  70364. declare class XRRigidTransform {
  70365. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70366. position: DOMPointReadOnly;
  70367. orientation: DOMPointReadOnly;
  70368. matrix: Float32Array;
  70369. inverse: XRRigidTransform;
  70370. }
  70371. interface XRView {
  70372. eye: XREye;
  70373. projectionMatrix: Float32Array;
  70374. transform: XRRigidTransform;
  70375. }
  70376. interface XRInputSourceChangeEvent {
  70377. session: XRSession;
  70378. removed: Array<XRInputSource>;
  70379. added: Array<XRInputSource>;
  70380. }
  70381. interface XRInputSourceEvent extends Event {
  70382. readonly frame: XRFrame;
  70383. readonly inputSource: XRInputSource;
  70384. }
  70385. // Experimental(er) features
  70386. declare class XRRay {
  70387. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70388. origin: DOMPointReadOnly;
  70389. direction: DOMPointReadOnly;
  70390. matrix: Float32Array;
  70391. }
  70392. interface XRHitResult {
  70393. hitMatrix: Float32Array;
  70394. }
  70395. interface XRAnchor {
  70396. // remove?
  70397. id?: string;
  70398. anchorSpace: XRSpace;
  70399. lastChangedTime: number;
  70400. detach(): void;
  70401. }
  70402. interface XRPlane extends XRAnchorCreator {
  70403. orientation: "Horizontal" | "Vertical";
  70404. planeSpace: XRSpace;
  70405. polygon: Array<DOMPointReadOnly>;
  70406. lastChangedTime: number;
  70407. }
  70408. interface XRAnchorCreator {
  70409. // AR Anchors
  70410. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70411. }
  70412. /**
  70413. * @ignore
  70414. */
  70415. declare module BABYLON.GLTF2.Exporter {
  70416. }
  70417. /**
  70418. * @ignore
  70419. */
  70420. declare module BABYLON.GLTF1 {
  70421. }
  70422. declare module BABYLON.GUI {
  70423. /**
  70424. * Class used to specific a value and its associated unit
  70425. */
  70426. export class ValueAndUnit {
  70427. /** defines the unit to store */
  70428. unit: number;
  70429. /** defines a boolean indicating if the value can be negative */
  70430. negativeValueAllowed: boolean;
  70431. private _value;
  70432. private _originalUnit;
  70433. /**
  70434. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70435. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70436. */
  70437. ignoreAdaptiveScaling: boolean;
  70438. /**
  70439. * Creates a new ValueAndUnit
  70440. * @param value defines the value to store
  70441. * @param unit defines the unit to store
  70442. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70443. */
  70444. constructor(value: number,
  70445. /** defines the unit to store */
  70446. unit?: number,
  70447. /** defines a boolean indicating if the value can be negative */
  70448. negativeValueAllowed?: boolean);
  70449. /** Gets a boolean indicating if the value is a percentage */
  70450. get isPercentage(): boolean;
  70451. /** Gets a boolean indicating if the value is store as pixel */
  70452. get isPixel(): boolean;
  70453. /** Gets direct internal value */
  70454. get internalValue(): number;
  70455. /**
  70456. * Gets value as pixel
  70457. * @param host defines the root host
  70458. * @param refValue defines the reference value for percentages
  70459. * @returns the value as pixel
  70460. */
  70461. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70462. /**
  70463. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70464. * @param value defines the value to store
  70465. * @param unit defines the unit to store
  70466. * @returns the current ValueAndUnit
  70467. */
  70468. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70469. /**
  70470. * Gets the value accordingly to its unit
  70471. * @param host defines the root host
  70472. * @returns the value
  70473. */
  70474. getValue(host: AdvancedDynamicTexture): number;
  70475. /**
  70476. * Gets a string representation of the value
  70477. * @param host defines the root host
  70478. * @param decimals defines an optional number of decimals to display
  70479. * @returns a string
  70480. */
  70481. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70482. /**
  70483. * Store a value parsed from a string
  70484. * @param source defines the source string
  70485. * @returns true if the value was successfully parsed
  70486. */
  70487. fromString(source: string | number): boolean;
  70488. private static _Regex;
  70489. private static _UNITMODE_PERCENTAGE;
  70490. private static _UNITMODE_PIXEL;
  70491. /** UNITMODE_PERCENTAGE */
  70492. static get UNITMODE_PERCENTAGE(): number;
  70493. /** UNITMODE_PIXEL */
  70494. static get UNITMODE_PIXEL(): number;
  70495. }
  70496. }
  70497. declare module BABYLON.GUI {
  70498. /**
  70499. * Define a style used by control to automatically setup properties based on a template.
  70500. * Only support font related properties so far
  70501. */
  70502. export class Style implements BABYLON.IDisposable {
  70503. private _fontFamily;
  70504. private _fontStyle;
  70505. private _fontWeight;
  70506. /** @hidden */
  70507. _host: AdvancedDynamicTexture;
  70508. /** @hidden */
  70509. _fontSize: ValueAndUnit;
  70510. /**
  70511. * BABYLON.Observable raised when the style values are changed
  70512. */
  70513. onChangedObservable: BABYLON.Observable<Style>;
  70514. /**
  70515. * Creates a new style object
  70516. * @param host defines the AdvancedDynamicTexture which hosts this style
  70517. */
  70518. constructor(host: AdvancedDynamicTexture);
  70519. /**
  70520. * Gets or sets the font size
  70521. */
  70522. get fontSize(): string | number;
  70523. set fontSize(value: string | number);
  70524. /**
  70525. * Gets or sets the font family
  70526. */
  70527. get fontFamily(): string;
  70528. set fontFamily(value: string);
  70529. /**
  70530. * Gets or sets the font style
  70531. */
  70532. get fontStyle(): string;
  70533. set fontStyle(value: string);
  70534. /** Gets or sets font weight */
  70535. get fontWeight(): string;
  70536. set fontWeight(value: string);
  70537. /** Dispose all associated resources */
  70538. dispose(): void;
  70539. }
  70540. }
  70541. declare module BABYLON.GUI {
  70542. /**
  70543. * Class used to transport BABYLON.Vector2 information for pointer events
  70544. */
  70545. export class Vector2WithInfo extends BABYLON.Vector2 {
  70546. /** defines the current mouse button index */
  70547. buttonIndex: number;
  70548. /**
  70549. * Creates a new Vector2WithInfo
  70550. * @param source defines the vector2 data to transport
  70551. * @param buttonIndex defines the current mouse button index
  70552. */
  70553. constructor(source: BABYLON.Vector2,
  70554. /** defines the current mouse button index */
  70555. buttonIndex?: number);
  70556. }
  70557. /** Class used to provide 2D matrix features */
  70558. export class Matrix2D {
  70559. /** Gets the internal array of 6 floats used to store matrix data */
  70560. m: Float32Array;
  70561. /**
  70562. * Creates a new matrix
  70563. * @param m00 defines value for (0, 0)
  70564. * @param m01 defines value for (0, 1)
  70565. * @param m10 defines value for (1, 0)
  70566. * @param m11 defines value for (1, 1)
  70567. * @param m20 defines value for (2, 0)
  70568. * @param m21 defines value for (2, 1)
  70569. */
  70570. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70571. /**
  70572. * Fills the matrix from direct values
  70573. * @param m00 defines value for (0, 0)
  70574. * @param m01 defines value for (0, 1)
  70575. * @param m10 defines value for (1, 0)
  70576. * @param m11 defines value for (1, 1)
  70577. * @param m20 defines value for (2, 0)
  70578. * @param m21 defines value for (2, 1)
  70579. * @returns the current modified matrix
  70580. */
  70581. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70582. /**
  70583. * Gets matrix determinant
  70584. * @returns the determinant
  70585. */
  70586. determinant(): number;
  70587. /**
  70588. * Inverses the matrix and stores it in a target matrix
  70589. * @param result defines the target matrix
  70590. * @returns the current matrix
  70591. */
  70592. invertToRef(result: Matrix2D): Matrix2D;
  70593. /**
  70594. * Multiplies the current matrix with another one
  70595. * @param other defines the second operand
  70596. * @param result defines the target matrix
  70597. * @returns the current matrix
  70598. */
  70599. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70600. /**
  70601. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70602. * @param x defines the x coordinate to transform
  70603. * @param y defines the x coordinate to transform
  70604. * @param result defines the target vector2
  70605. * @returns the current matrix
  70606. */
  70607. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70608. /**
  70609. * Creates an identity matrix
  70610. * @returns a new matrix
  70611. */
  70612. static Identity(): Matrix2D;
  70613. /**
  70614. * Creates a translation matrix and stores it in a target matrix
  70615. * @param x defines the x coordinate of the translation
  70616. * @param y defines the y coordinate of the translation
  70617. * @param result defines the target matrix
  70618. */
  70619. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70620. /**
  70621. * Creates a scaling matrix and stores it in a target matrix
  70622. * @param x defines the x coordinate of the scaling
  70623. * @param y defines the y coordinate of the scaling
  70624. * @param result defines the target matrix
  70625. */
  70626. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70627. /**
  70628. * Creates a rotation matrix and stores it in a target matrix
  70629. * @param angle defines the rotation angle
  70630. * @param result defines the target matrix
  70631. */
  70632. static RotationToRef(angle: number, result: Matrix2D): void;
  70633. private static _TempPreTranslationMatrix;
  70634. private static _TempPostTranslationMatrix;
  70635. private static _TempRotationMatrix;
  70636. private static _TempScalingMatrix;
  70637. private static _TempCompose0;
  70638. private static _TempCompose1;
  70639. private static _TempCompose2;
  70640. /**
  70641. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70642. * @param tx defines the x coordinate of the translation
  70643. * @param ty defines the y coordinate of the translation
  70644. * @param angle defines the rotation angle
  70645. * @param scaleX defines the x coordinate of the scaling
  70646. * @param scaleY defines the y coordinate of the scaling
  70647. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70648. * @param result defines the target matrix
  70649. */
  70650. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70651. }
  70652. }
  70653. declare module BABYLON.GUI {
  70654. /**
  70655. * Class used to store 2D control sizes
  70656. */
  70657. export class Measure {
  70658. /** defines left coordinate */
  70659. left: number;
  70660. /** defines top coordinate */
  70661. top: number;
  70662. /** defines width dimension */
  70663. width: number;
  70664. /** defines height dimension */
  70665. height: number;
  70666. /**
  70667. * Creates a new measure
  70668. * @param left defines left coordinate
  70669. * @param top defines top coordinate
  70670. * @param width defines width dimension
  70671. * @param height defines height dimension
  70672. */
  70673. constructor(
  70674. /** defines left coordinate */
  70675. left: number,
  70676. /** defines top coordinate */
  70677. top: number,
  70678. /** defines width dimension */
  70679. width: number,
  70680. /** defines height dimension */
  70681. height: number);
  70682. /**
  70683. * Copy from another measure
  70684. * @param other defines the other measure to copy from
  70685. */
  70686. copyFrom(other: Measure): void;
  70687. /**
  70688. * Copy from a group of 4 floats
  70689. * @param left defines left coordinate
  70690. * @param top defines top coordinate
  70691. * @param width defines width dimension
  70692. * @param height defines height dimension
  70693. */
  70694. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70695. /**
  70696. * Computes the axis aligned bounding box measure for two given measures
  70697. * @param a Input measure
  70698. * @param b Input measure
  70699. * @param result the resulting bounding measure
  70700. */
  70701. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70702. /**
  70703. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70704. * @param transform the matrix to transform the measure before computing the AABB
  70705. * @param result the resulting AABB
  70706. */
  70707. transformToRef(transform: Matrix2D, result: Measure): void;
  70708. /**
  70709. * Check equality between this measure and another one
  70710. * @param other defines the other measures
  70711. * @returns true if both measures are equals
  70712. */
  70713. isEqualsTo(other: Measure): boolean;
  70714. /**
  70715. * Creates an empty measure
  70716. * @returns a new measure
  70717. */
  70718. static Empty(): Measure;
  70719. }
  70720. }
  70721. declare module BABYLON.GUI {
  70722. /**
  70723. * Interface used to define a control that can receive focus
  70724. */
  70725. export interface IFocusableControl {
  70726. /**
  70727. * Function called when the control receives the focus
  70728. */
  70729. onFocus(): void;
  70730. /**
  70731. * Function called when the control loses the focus
  70732. */
  70733. onBlur(): void;
  70734. /**
  70735. * Function called to let the control handle keyboard events
  70736. * @param evt defines the current keyboard event
  70737. */
  70738. processKeyboard(evt: KeyboardEvent): void;
  70739. /**
  70740. * Function called to get the list of controls that should not steal the focus from this control
  70741. * @returns an array of controls
  70742. */
  70743. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70744. }
  70745. /**
  70746. * Class used to create texture to support 2D GUI elements
  70747. * @see http://doc.babylonjs.com/how_to/gui
  70748. */
  70749. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70750. private _isDirty;
  70751. private _renderObserver;
  70752. private _resizeObserver;
  70753. private _preKeyboardObserver;
  70754. private _pointerMoveObserver;
  70755. private _pointerObserver;
  70756. private _canvasPointerOutObserver;
  70757. private _background;
  70758. /** @hidden */
  70759. _rootContainer: Container;
  70760. /** @hidden */
  70761. _lastPickedControl: Control;
  70762. /** @hidden */
  70763. _lastControlOver: {
  70764. [pointerId: number]: Control;
  70765. };
  70766. /** @hidden */
  70767. _lastControlDown: {
  70768. [pointerId: number]: Control;
  70769. };
  70770. /** @hidden */
  70771. _capturingControl: {
  70772. [pointerId: number]: Control;
  70773. };
  70774. /** @hidden */
  70775. _shouldBlockPointer: boolean;
  70776. /** @hidden */
  70777. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70778. /** @hidden */
  70779. _linkedControls: Control[];
  70780. private _isFullscreen;
  70781. private _fullscreenViewport;
  70782. private _idealWidth;
  70783. private _idealHeight;
  70784. private _useSmallestIdeal;
  70785. private _renderAtIdealSize;
  70786. private _focusedControl;
  70787. private _blockNextFocusCheck;
  70788. private _renderScale;
  70789. private _rootElement;
  70790. private _cursorChanged;
  70791. private _defaultMousePointerId;
  70792. /** @hidden */
  70793. _numLayoutCalls: number;
  70794. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70795. get numLayoutCalls(): number;
  70796. /** @hidden */
  70797. _numRenderCalls: number;
  70798. /** Gets the number of render calls made the last time the ADT has been rendered */
  70799. get numRenderCalls(): number;
  70800. /**
  70801. * Define type to string to ensure compatibility across browsers
  70802. * Safari doesn't support DataTransfer constructor
  70803. */
  70804. private _clipboardData;
  70805. /**
  70806. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70807. */
  70808. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70809. /**
  70810. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70811. */
  70812. onControlPickedObservable: BABYLON.Observable<Control>;
  70813. /**
  70814. * BABYLON.Observable event triggered before layout is evaluated
  70815. */
  70816. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70817. /**
  70818. * BABYLON.Observable event triggered after the layout was evaluated
  70819. */
  70820. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70821. /**
  70822. * BABYLON.Observable event triggered before the texture is rendered
  70823. */
  70824. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70825. /**
  70826. * BABYLON.Observable event triggered after the texture was rendered
  70827. */
  70828. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70829. /**
  70830. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70831. */
  70832. premulAlpha: boolean;
  70833. /**
  70834. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70835. * Useful when you want more antialiasing
  70836. */
  70837. get renderScale(): number;
  70838. set renderScale(value: number);
  70839. /** Gets or sets the background color */
  70840. get background(): string;
  70841. set background(value: string);
  70842. /**
  70843. * Gets or sets the ideal width used to design controls.
  70844. * The GUI will then rescale everything accordingly
  70845. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70846. */
  70847. get idealWidth(): number;
  70848. set idealWidth(value: number);
  70849. /**
  70850. * Gets or sets the ideal height used to design controls.
  70851. * The GUI will then rescale everything accordingly
  70852. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70853. */
  70854. get idealHeight(): number;
  70855. set idealHeight(value: number);
  70856. /**
  70857. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70858. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70859. */
  70860. get useSmallestIdeal(): boolean;
  70861. set useSmallestIdeal(value: boolean);
  70862. /**
  70863. * Gets or sets a boolean indicating if adaptive scaling must be used
  70864. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70865. */
  70866. get renderAtIdealSize(): boolean;
  70867. set renderAtIdealSize(value: boolean);
  70868. /**
  70869. * Gets the ratio used when in "ideal mode"
  70870. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70871. * */
  70872. get idealRatio(): number;
  70873. /**
  70874. * Gets the underlying layer used to render the texture when in fullscreen mode
  70875. */
  70876. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70877. /**
  70878. * Gets the root container control
  70879. */
  70880. get rootContainer(): Container;
  70881. /**
  70882. * Returns an array containing the root container.
  70883. * This is mostly used to let the Inspector introspects the ADT
  70884. * @returns an array containing the rootContainer
  70885. */
  70886. getChildren(): Array<Container>;
  70887. /**
  70888. * Will return all controls that are inside this texture
  70889. * @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
  70890. * @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
  70891. * @return all child controls
  70892. */
  70893. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70894. /**
  70895. * Gets or sets the current focused control
  70896. */
  70897. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70898. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70899. /**
  70900. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70901. */
  70902. get isForeground(): boolean;
  70903. set isForeground(value: boolean);
  70904. /**
  70905. * Gets or set information about clipboardData
  70906. */
  70907. get clipboardData(): string;
  70908. set clipboardData(value: string);
  70909. /**
  70910. * Creates a new AdvancedDynamicTexture
  70911. * @param name defines the name of the texture
  70912. * @param width defines the width of the texture
  70913. * @param height defines the height of the texture
  70914. * @param scene defines the hosting scene
  70915. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70916. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70917. */
  70918. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70919. /**
  70920. * Get the current class name of the texture useful for serialization or dynamic coding.
  70921. * @returns "AdvancedDynamicTexture"
  70922. */
  70923. getClassName(): string;
  70924. /**
  70925. * Function used to execute a function on all controls
  70926. * @param func defines the function to execute
  70927. * @param container defines the container where controls belong. If null the root container will be used
  70928. */
  70929. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70930. private _useInvalidateRectOptimization;
  70931. /**
  70932. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70933. */
  70934. get useInvalidateRectOptimization(): boolean;
  70935. set useInvalidateRectOptimization(value: boolean);
  70936. private _invalidatedRectangle;
  70937. /**
  70938. * Invalidates a rectangle area on the gui texture
  70939. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70940. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70941. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70942. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70943. */
  70944. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70945. /**
  70946. * Marks the texture as dirty forcing a complete update
  70947. */
  70948. markAsDirty(): void;
  70949. /**
  70950. * Helper function used to create a new style
  70951. * @returns a new style
  70952. * @see http://doc.babylonjs.com/how_to/gui#styles
  70953. */
  70954. createStyle(): Style;
  70955. /**
  70956. * Adds a new control to the root container
  70957. * @param control defines the control to add
  70958. * @returns the current texture
  70959. */
  70960. addControl(control: Control): AdvancedDynamicTexture;
  70961. /**
  70962. * Removes a control from the root container
  70963. * @param control defines the control to remove
  70964. * @returns the current texture
  70965. */
  70966. removeControl(control: Control): AdvancedDynamicTexture;
  70967. /**
  70968. * Release all resources
  70969. */
  70970. dispose(): void;
  70971. private _onResize;
  70972. /** @hidden */
  70973. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70974. /**
  70975. * Get screen coordinates for a vector3
  70976. * @param position defines the position to project
  70977. * @param worldMatrix defines the world matrix to use
  70978. * @returns the projected position
  70979. */
  70980. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70981. private _checkUpdate;
  70982. private _clearMeasure;
  70983. private _render;
  70984. /** @hidden */
  70985. _changeCursor(cursor: string): void;
  70986. /** @hidden */
  70987. _registerLastControlDown(control: Control, pointerId: number): void;
  70988. private _doPicking;
  70989. /** @hidden */
  70990. _cleanControlAfterRemovalFromList(list: {
  70991. [pointerId: number]: Control;
  70992. }, control: Control): void;
  70993. /** @hidden */
  70994. _cleanControlAfterRemoval(control: Control): void;
  70995. /** Attach to all scene events required to support pointer events */
  70996. attach(): void;
  70997. /** @hidden */
  70998. private onClipboardCopy;
  70999. /** @hidden */
  71000. private onClipboardCut;
  71001. /** @hidden */
  71002. private onClipboardPaste;
  71003. /**
  71004. * Register the clipboard Events onto the canvas
  71005. */
  71006. registerClipboardEvents(): void;
  71007. /**
  71008. * Unregister the clipboard Events from the canvas
  71009. */
  71010. unRegisterClipboardEvents(): void;
  71011. /**
  71012. * Connect the texture to a hosting mesh to enable interactions
  71013. * @param mesh defines the mesh to attach to
  71014. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71015. */
  71016. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71017. /**
  71018. * Move the focus to a specific control
  71019. * @param control defines the control which will receive the focus
  71020. */
  71021. moveFocusToControl(control: IFocusableControl): void;
  71022. private _manageFocus;
  71023. private _attachToOnPointerOut;
  71024. /**
  71025. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71026. * @param mesh defines the mesh which will receive the texture
  71027. * @param width defines the texture width (1024 by default)
  71028. * @param height defines the texture height (1024 by default)
  71029. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71030. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71031. * @returns a new AdvancedDynamicTexture
  71032. */
  71033. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71034. /**
  71035. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71036. * In this mode the texture will rely on a layer for its rendering.
  71037. * This allows it to be treated like any other layer.
  71038. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71039. * LayerMask is set through advancedTexture.layer.layerMask
  71040. * @param name defines name for the texture
  71041. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71042. * @param scene defines the hsoting scene
  71043. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71044. * @returns a new AdvancedDynamicTexture
  71045. */
  71046. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71047. }
  71048. }
  71049. declare module BABYLON.GUI {
  71050. /**
  71051. * Root class used for all 2D controls
  71052. * @see http://doc.babylonjs.com/how_to/gui#controls
  71053. */
  71054. export class Control {
  71055. /** defines the name of the control */
  71056. name?: string | undefined;
  71057. /**
  71058. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71059. */
  71060. static AllowAlphaInheritance: boolean;
  71061. private _alpha;
  71062. private _alphaSet;
  71063. private _zIndex;
  71064. /** @hidden */
  71065. _host: AdvancedDynamicTexture;
  71066. /** Gets or sets the control parent */
  71067. parent: BABYLON.Nullable<Container>;
  71068. /** @hidden */
  71069. _currentMeasure: Measure;
  71070. private _fontFamily;
  71071. private _fontStyle;
  71072. private _fontWeight;
  71073. private _fontSize;
  71074. private _font;
  71075. /** @hidden */
  71076. _width: ValueAndUnit;
  71077. /** @hidden */
  71078. _height: ValueAndUnit;
  71079. /** @hidden */
  71080. protected _fontOffset: {
  71081. ascent: number;
  71082. height: number;
  71083. descent: number;
  71084. };
  71085. private _color;
  71086. private _style;
  71087. private _styleObserver;
  71088. /** @hidden */
  71089. protected _horizontalAlignment: number;
  71090. /** @hidden */
  71091. protected _verticalAlignment: number;
  71092. /** @hidden */
  71093. protected _isDirty: boolean;
  71094. /** @hidden */
  71095. protected _wasDirty: boolean;
  71096. /** @hidden */
  71097. _tempParentMeasure: Measure;
  71098. /** @hidden */
  71099. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71100. /** @hidden */
  71101. protected _cachedParentMeasure: Measure;
  71102. private _paddingLeft;
  71103. private _paddingRight;
  71104. private _paddingTop;
  71105. private _paddingBottom;
  71106. /** @hidden */
  71107. _left: ValueAndUnit;
  71108. /** @hidden */
  71109. _top: ValueAndUnit;
  71110. private _scaleX;
  71111. private _scaleY;
  71112. private _rotation;
  71113. private _transformCenterX;
  71114. private _transformCenterY;
  71115. /** @hidden */
  71116. _transformMatrix: Matrix2D;
  71117. /** @hidden */
  71118. protected _invertTransformMatrix: Matrix2D;
  71119. /** @hidden */
  71120. protected _transformedPosition: BABYLON.Vector2;
  71121. private _isMatrixDirty;
  71122. private _cachedOffsetX;
  71123. private _cachedOffsetY;
  71124. private _isVisible;
  71125. private _isHighlighted;
  71126. /** @hidden */
  71127. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71128. private _fontSet;
  71129. private _dummyVector2;
  71130. private _downCount;
  71131. private _enterCount;
  71132. private _doNotRender;
  71133. private _downPointerIds;
  71134. protected _isEnabled: boolean;
  71135. protected _disabledColor: string;
  71136. protected _disabledColorItem: string;
  71137. /** @hidden */
  71138. protected _rebuildLayout: boolean;
  71139. /** @hidden */
  71140. _customData: any;
  71141. /** @hidden */
  71142. _isClipped: boolean;
  71143. /** @hidden */
  71144. _automaticSize: boolean;
  71145. /** @hidden */
  71146. _tag: any;
  71147. /**
  71148. * 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
  71149. */
  71150. uniqueId: number;
  71151. /**
  71152. * Gets or sets an object used to store user defined information for the node
  71153. */
  71154. metadata: any;
  71155. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71156. isHitTestVisible: boolean;
  71157. /** Gets or sets a boolean indicating if the control can block pointer events */
  71158. isPointerBlocker: boolean;
  71159. /** Gets or sets a boolean indicating if the control can be focusable */
  71160. isFocusInvisible: boolean;
  71161. /**
  71162. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71163. * 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
  71164. */
  71165. clipChildren: boolean;
  71166. /**
  71167. * Gets or sets a boolean indicating that control content must be clipped
  71168. * 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
  71169. */
  71170. clipContent: boolean;
  71171. /**
  71172. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71173. */
  71174. useBitmapCache: boolean;
  71175. private _cacheData;
  71176. private _shadowOffsetX;
  71177. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71178. get shadowOffsetX(): number;
  71179. set shadowOffsetX(value: number);
  71180. private _shadowOffsetY;
  71181. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71182. get shadowOffsetY(): number;
  71183. set shadowOffsetY(value: number);
  71184. private _shadowBlur;
  71185. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71186. get shadowBlur(): number;
  71187. set shadowBlur(value: number);
  71188. private _shadowColor;
  71189. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71190. get shadowColor(): string;
  71191. set shadowColor(value: string);
  71192. /** Gets or sets the cursor to use when the control is hovered */
  71193. hoverCursor: string;
  71194. /** @hidden */
  71195. protected _linkOffsetX: ValueAndUnit;
  71196. /** @hidden */
  71197. protected _linkOffsetY: ValueAndUnit;
  71198. /** Gets the control type name */
  71199. get typeName(): string;
  71200. /**
  71201. * Get the current class name of the control.
  71202. * @returns current class name
  71203. */
  71204. getClassName(): string;
  71205. /**
  71206. * An event triggered when pointer wheel is scrolled
  71207. */
  71208. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71209. /**
  71210. * An event triggered when the pointer move over the control.
  71211. */
  71212. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71213. /**
  71214. * An event triggered when the pointer move out of the control.
  71215. */
  71216. onPointerOutObservable: BABYLON.Observable<Control>;
  71217. /**
  71218. * An event triggered when the pointer taps the control
  71219. */
  71220. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71221. /**
  71222. * An event triggered when pointer up
  71223. */
  71224. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71225. /**
  71226. * An event triggered when a control is clicked on
  71227. */
  71228. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71229. /**
  71230. * An event triggered when pointer enters the control
  71231. */
  71232. onPointerEnterObservable: BABYLON.Observable<Control>;
  71233. /**
  71234. * An event triggered when the control is marked as dirty
  71235. */
  71236. onDirtyObservable: BABYLON.Observable<Control>;
  71237. /**
  71238. * An event triggered before drawing the control
  71239. */
  71240. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71241. /**
  71242. * An event triggered after the control was drawn
  71243. */
  71244. onAfterDrawObservable: BABYLON.Observable<Control>;
  71245. /**
  71246. * Get the hosting AdvancedDynamicTexture
  71247. */
  71248. get host(): AdvancedDynamicTexture;
  71249. /** Gets or set information about font offsets (used to render and align text) */
  71250. get fontOffset(): {
  71251. ascent: number;
  71252. height: number;
  71253. descent: number;
  71254. };
  71255. set fontOffset(offset: {
  71256. ascent: number;
  71257. height: number;
  71258. descent: number;
  71259. });
  71260. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71261. get alpha(): number;
  71262. set alpha(value: number);
  71263. /**
  71264. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71265. */
  71266. get isHighlighted(): boolean;
  71267. set isHighlighted(value: boolean);
  71268. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71269. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71270. */
  71271. get scaleX(): number;
  71272. set scaleX(value: number);
  71273. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71274. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71275. */
  71276. get scaleY(): number;
  71277. set scaleY(value: number);
  71278. /** Gets or sets the rotation angle (0 by default)
  71279. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71280. */
  71281. get rotation(): number;
  71282. set rotation(value: number);
  71283. /** Gets or sets the transformation center on Y axis (0 by default)
  71284. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71285. */
  71286. get transformCenterY(): number;
  71287. set transformCenterY(value: number);
  71288. /** Gets or sets the transformation center on X axis (0 by default)
  71289. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71290. */
  71291. get transformCenterX(): number;
  71292. set transformCenterX(value: number);
  71293. /**
  71294. * Gets or sets the horizontal alignment
  71295. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71296. */
  71297. get horizontalAlignment(): number;
  71298. set horizontalAlignment(value: number);
  71299. /**
  71300. * Gets or sets the vertical alignment
  71301. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71302. */
  71303. get verticalAlignment(): number;
  71304. set verticalAlignment(value: number);
  71305. /**
  71306. * Gets or sets control width
  71307. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71308. */
  71309. get width(): string | number;
  71310. set width(value: string | number);
  71311. /**
  71312. * Gets or sets the control width in pixel
  71313. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71314. */
  71315. get widthInPixels(): number;
  71316. set widthInPixels(value: number);
  71317. /**
  71318. * Gets or sets control height
  71319. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71320. */
  71321. get height(): string | number;
  71322. set height(value: string | number);
  71323. /**
  71324. * Gets or sets control height in pixel
  71325. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71326. */
  71327. get heightInPixels(): number;
  71328. set heightInPixels(value: number);
  71329. /** Gets or set font family */
  71330. get fontFamily(): string;
  71331. set fontFamily(value: string);
  71332. /** Gets or sets font style */
  71333. get fontStyle(): string;
  71334. set fontStyle(value: string);
  71335. /** Gets or sets font weight */
  71336. get fontWeight(): string;
  71337. set fontWeight(value: string);
  71338. /**
  71339. * Gets or sets style
  71340. * @see http://doc.babylonjs.com/how_to/gui#styles
  71341. */
  71342. get style(): BABYLON.Nullable<Style>;
  71343. set style(value: BABYLON.Nullable<Style>);
  71344. /** @hidden */
  71345. get _isFontSizeInPercentage(): boolean;
  71346. /** Gets or sets font size in pixels */
  71347. get fontSizeInPixels(): number;
  71348. set fontSizeInPixels(value: number);
  71349. /** Gets or sets font size */
  71350. get fontSize(): string | number;
  71351. set fontSize(value: string | number);
  71352. /** Gets or sets foreground color */
  71353. get color(): string;
  71354. set color(value: string);
  71355. /** Gets or sets z index which is used to reorder controls on the z axis */
  71356. get zIndex(): number;
  71357. set zIndex(value: number);
  71358. /** Gets or sets a boolean indicating if the control can be rendered */
  71359. get notRenderable(): boolean;
  71360. set notRenderable(value: boolean);
  71361. /** Gets or sets a boolean indicating if the control is visible */
  71362. get isVisible(): boolean;
  71363. set isVisible(value: boolean);
  71364. /** Gets a boolean indicating that the control needs to update its rendering */
  71365. get isDirty(): boolean;
  71366. /**
  71367. * Gets the current linked mesh (or null if none)
  71368. */
  71369. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71370. /**
  71371. * Gets or sets a value indicating the padding to use on the left of the control
  71372. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71373. */
  71374. get paddingLeft(): string | number;
  71375. set paddingLeft(value: string | number);
  71376. /**
  71377. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71378. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71379. */
  71380. get paddingLeftInPixels(): number;
  71381. set paddingLeftInPixels(value: number);
  71382. /**
  71383. * Gets or sets a value indicating the padding to use on the right of the control
  71384. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71385. */
  71386. get paddingRight(): string | number;
  71387. set paddingRight(value: string | number);
  71388. /**
  71389. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71390. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71391. */
  71392. get paddingRightInPixels(): number;
  71393. set paddingRightInPixels(value: number);
  71394. /**
  71395. * Gets or sets a value indicating the padding to use on the top of the control
  71396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71397. */
  71398. get paddingTop(): string | number;
  71399. set paddingTop(value: string | number);
  71400. /**
  71401. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71402. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71403. */
  71404. get paddingTopInPixels(): number;
  71405. set paddingTopInPixels(value: number);
  71406. /**
  71407. * Gets or sets a value indicating the padding to use on the bottom of the control
  71408. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71409. */
  71410. get paddingBottom(): string | number;
  71411. set paddingBottom(value: string | number);
  71412. /**
  71413. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71414. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71415. */
  71416. get paddingBottomInPixels(): number;
  71417. set paddingBottomInPixels(value: number);
  71418. /**
  71419. * Gets or sets a value indicating the left coordinate of the control
  71420. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71421. */
  71422. get left(): string | number;
  71423. set left(value: string | number);
  71424. /**
  71425. * Gets or sets a value indicating the left coordinate in pixels of the control
  71426. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71427. */
  71428. get leftInPixels(): number;
  71429. set leftInPixels(value: number);
  71430. /**
  71431. * Gets or sets a value indicating the top coordinate of the control
  71432. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71433. */
  71434. get top(): string | number;
  71435. set top(value: string | number);
  71436. /**
  71437. * Gets or sets a value indicating the top coordinate in pixels of the control
  71438. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71439. */
  71440. get topInPixels(): number;
  71441. set topInPixels(value: number);
  71442. /**
  71443. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71444. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71445. */
  71446. get linkOffsetX(): string | number;
  71447. set linkOffsetX(value: string | number);
  71448. /**
  71449. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71450. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71451. */
  71452. get linkOffsetXInPixels(): number;
  71453. set linkOffsetXInPixels(value: number);
  71454. /**
  71455. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71456. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71457. */
  71458. get linkOffsetY(): string | number;
  71459. set linkOffsetY(value: string | number);
  71460. /**
  71461. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71463. */
  71464. get linkOffsetYInPixels(): number;
  71465. set linkOffsetYInPixels(value: number);
  71466. /** Gets the center coordinate on X axis */
  71467. get centerX(): number;
  71468. /** Gets the center coordinate on Y axis */
  71469. get centerY(): number;
  71470. /** Gets or sets if control is Enabled*/
  71471. get isEnabled(): boolean;
  71472. set isEnabled(value: boolean);
  71473. /** Gets or sets background color of control if it's disabled*/
  71474. get disabledColor(): string;
  71475. set disabledColor(value: string);
  71476. /** Gets or sets front color of control if it's disabled*/
  71477. get disabledColorItem(): string;
  71478. set disabledColorItem(value: string);
  71479. /**
  71480. * Creates a new control
  71481. * @param name defines the name of the control
  71482. */
  71483. constructor(
  71484. /** defines the name of the control */
  71485. name?: string | undefined);
  71486. /** @hidden */
  71487. protected _getTypeName(): string;
  71488. /**
  71489. * Gets the first ascendant in the hierarchy of the given type
  71490. * @param className defines the required type
  71491. * @returns the ascendant or null if not found
  71492. */
  71493. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71494. /** @hidden */
  71495. _resetFontCache(): void;
  71496. /**
  71497. * Determines if a container is an ascendant of the current control
  71498. * @param container defines the container to look for
  71499. * @returns true if the container is one of the ascendant of the control
  71500. */
  71501. isAscendant(container: Control): boolean;
  71502. /**
  71503. * Gets coordinates in local control space
  71504. * @param globalCoordinates defines the coordinates to transform
  71505. * @returns the new coordinates in local space
  71506. */
  71507. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71508. /**
  71509. * Gets coordinates in local control space
  71510. * @param globalCoordinates defines the coordinates to transform
  71511. * @param result defines the target vector2 where to store the result
  71512. * @returns the current control
  71513. */
  71514. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71515. /**
  71516. * Gets coordinates in parent local control space
  71517. * @param globalCoordinates defines the coordinates to transform
  71518. * @returns the new coordinates in parent local space
  71519. */
  71520. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71521. /**
  71522. * Move the current control to a vector3 position projected onto the screen.
  71523. * @param position defines the target position
  71524. * @param scene defines the hosting scene
  71525. */
  71526. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71527. /**
  71528. * Will store all controls that have this control as ascendant in a given array
  71529. * @param results defines the array where to store the descendants
  71530. * @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
  71531. * @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
  71532. */
  71533. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71534. /**
  71535. * Will return all controls that have this control as ascendant
  71536. * @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
  71537. * @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
  71538. * @return all child controls
  71539. */
  71540. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71541. /**
  71542. * Link current control with a target mesh
  71543. * @param mesh defines the mesh to link with
  71544. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71545. */
  71546. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71547. /** @hidden */
  71548. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71549. /** @hidden */
  71550. _offsetLeft(offset: number): void;
  71551. /** @hidden */
  71552. _offsetTop(offset: number): void;
  71553. /** @hidden */
  71554. _markMatrixAsDirty(): void;
  71555. /** @hidden */
  71556. _flagDescendantsAsMatrixDirty(): void;
  71557. /** @hidden */
  71558. _intersectsRect(rect: Measure): boolean;
  71559. /** @hidden */
  71560. protected invalidateRect(): void;
  71561. /** @hidden */
  71562. _markAsDirty(force?: boolean): void;
  71563. /** @hidden */
  71564. _markAllAsDirty(): void;
  71565. /** @hidden */
  71566. _link(host: AdvancedDynamicTexture): void;
  71567. /** @hidden */
  71568. protected _transform(context?: CanvasRenderingContext2D): void;
  71569. /** @hidden */
  71570. _renderHighlight(context: CanvasRenderingContext2D): void;
  71571. /** @hidden */
  71572. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71573. /** @hidden */
  71574. protected _applyStates(context: CanvasRenderingContext2D): void;
  71575. /** @hidden */
  71576. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71577. /** @hidden */
  71578. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71579. protected _evaluateClippingState(parentMeasure: Measure): void;
  71580. /** @hidden */
  71581. _measure(): void;
  71582. /** @hidden */
  71583. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71584. /** @hidden */
  71585. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71586. /** @hidden */
  71587. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71588. /** @hidden */
  71589. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71590. private static _ClipMeasure;
  71591. private _tmpMeasureA;
  71592. private _clip;
  71593. /** @hidden */
  71594. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71595. /** @hidden */
  71596. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71597. /**
  71598. * Tests if a given coordinates belong to the current control
  71599. * @param x defines x coordinate to test
  71600. * @param y defines y coordinate to test
  71601. * @returns true if the coordinates are inside the control
  71602. */
  71603. contains(x: number, y: number): boolean;
  71604. /** @hidden */
  71605. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71606. /** @hidden */
  71607. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71608. /** @hidden */
  71609. _onPointerEnter(target: Control): boolean;
  71610. /** @hidden */
  71611. _onPointerOut(target: Control, force?: boolean): void;
  71612. /** @hidden */
  71613. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71614. /** @hidden */
  71615. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71616. /** @hidden */
  71617. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71618. /** @hidden */
  71619. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71620. /** @hidden */
  71621. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71622. private _prepareFont;
  71623. /** Releases associated resources */
  71624. dispose(): void;
  71625. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71626. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71627. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71628. private static _VERTICAL_ALIGNMENT_TOP;
  71629. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71630. private static _VERTICAL_ALIGNMENT_CENTER;
  71631. /** HORIZONTAL_ALIGNMENT_LEFT */
  71632. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71633. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71634. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71635. /** HORIZONTAL_ALIGNMENT_CENTER */
  71636. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71637. /** VERTICAL_ALIGNMENT_TOP */
  71638. static get VERTICAL_ALIGNMENT_TOP(): number;
  71639. /** VERTICAL_ALIGNMENT_BOTTOM */
  71640. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71641. /** VERTICAL_ALIGNMENT_CENTER */
  71642. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71643. private static _FontHeightSizes;
  71644. /** @hidden */
  71645. static _GetFontOffset(font: string): {
  71646. ascent: number;
  71647. height: number;
  71648. descent: number;
  71649. };
  71650. /**
  71651. * Creates a stack panel that can be used to render headers
  71652. * @param control defines the control to associate with the header
  71653. * @param text defines the text of the header
  71654. * @param size defines the size of the header
  71655. * @param options defines options used to configure the header
  71656. * @returns a new StackPanel
  71657. * @ignore
  71658. * @hidden
  71659. */
  71660. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71661. isHorizontal: boolean;
  71662. controlFirst: boolean;
  71663. }) => any;
  71664. /** @hidden */
  71665. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71666. }
  71667. }
  71668. declare module BABYLON.GUI {
  71669. /**
  71670. * Root class for 2D containers
  71671. * @see http://doc.babylonjs.com/how_to/gui#containers
  71672. */
  71673. export class Container extends Control {
  71674. name?: string | undefined;
  71675. /** @hidden */
  71676. _children: Control[];
  71677. /** @hidden */
  71678. protected _measureForChildren: Measure;
  71679. /** @hidden */
  71680. protected _background: string;
  71681. /** @hidden */
  71682. protected _adaptWidthToChildren: boolean;
  71683. /** @hidden */
  71684. protected _adaptHeightToChildren: boolean;
  71685. /**
  71686. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71687. */
  71688. logLayoutCycleErrors: boolean;
  71689. /**
  71690. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71691. */
  71692. maxLayoutCycle: number;
  71693. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71694. get adaptHeightToChildren(): boolean;
  71695. set adaptHeightToChildren(value: boolean);
  71696. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71697. get adaptWidthToChildren(): boolean;
  71698. set adaptWidthToChildren(value: boolean);
  71699. /** Gets or sets background color */
  71700. get background(): string;
  71701. set background(value: string);
  71702. /** Gets the list of children */
  71703. get children(): Control[];
  71704. /**
  71705. * Creates a new Container
  71706. * @param name defines the name of the container
  71707. */
  71708. constructor(name?: string | undefined);
  71709. protected _getTypeName(): string;
  71710. _flagDescendantsAsMatrixDirty(): void;
  71711. /**
  71712. * Gets a child using its name
  71713. * @param name defines the child name to look for
  71714. * @returns the child control if found
  71715. */
  71716. getChildByName(name: string): BABYLON.Nullable<Control>;
  71717. /**
  71718. * Gets a child using its type and its name
  71719. * @param name defines the child name to look for
  71720. * @param type defines the child type to look for
  71721. * @returns the child control if found
  71722. */
  71723. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71724. /**
  71725. * Search for a specific control in children
  71726. * @param control defines the control to look for
  71727. * @returns true if the control is in child list
  71728. */
  71729. containsControl(control: Control): boolean;
  71730. /**
  71731. * Adds a new control to the current container
  71732. * @param control defines the control to add
  71733. * @returns the current container
  71734. */
  71735. addControl(control: BABYLON.Nullable<Control>): Container;
  71736. /**
  71737. * Removes all controls from the current container
  71738. * @returns the current container
  71739. */
  71740. clearControls(): Container;
  71741. /**
  71742. * Removes a control from the current container
  71743. * @param control defines the control to remove
  71744. * @returns the current container
  71745. */
  71746. removeControl(control: Control): Container;
  71747. /** @hidden */
  71748. _reOrderControl(control: Control): void;
  71749. /** @hidden */
  71750. _offsetLeft(offset: number): void;
  71751. /** @hidden */
  71752. _offsetTop(offset: number): void;
  71753. /** @hidden */
  71754. _markAllAsDirty(): void;
  71755. /** @hidden */
  71756. protected _localDraw(context: CanvasRenderingContext2D): void;
  71757. /** @hidden */
  71758. _link(host: AdvancedDynamicTexture): void;
  71759. /** @hidden */
  71760. protected _beforeLayout(): void;
  71761. /** @hidden */
  71762. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71763. /** @hidden */
  71764. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71765. protected _postMeasure(): void;
  71766. /** @hidden */
  71767. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71768. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71769. /** @hidden */
  71770. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71771. /** @hidden */
  71772. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71773. /** Releases associated resources */
  71774. dispose(): void;
  71775. }
  71776. }
  71777. declare module BABYLON.GUI {
  71778. /** Class used to create rectangle container */
  71779. export class Rectangle extends Container {
  71780. name?: string | undefined;
  71781. private _thickness;
  71782. private _cornerRadius;
  71783. /** Gets or sets border thickness */
  71784. get thickness(): number;
  71785. set thickness(value: number);
  71786. /** Gets or sets the corner radius angle */
  71787. get cornerRadius(): number;
  71788. set cornerRadius(value: number);
  71789. /**
  71790. * Creates a new Rectangle
  71791. * @param name defines the control name
  71792. */
  71793. constructor(name?: string | undefined);
  71794. protected _getTypeName(): string;
  71795. protected _localDraw(context: CanvasRenderingContext2D): void;
  71796. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71797. private _drawRoundedRect;
  71798. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71799. }
  71800. }
  71801. declare module BABYLON.GUI {
  71802. /**
  71803. * Enum that determines the text-wrapping mode to use.
  71804. */
  71805. export enum TextWrapping {
  71806. /**
  71807. * Clip the text when it's larger than Control.width; this is the default mode.
  71808. */
  71809. Clip = 0,
  71810. /**
  71811. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71812. */
  71813. WordWrap = 1,
  71814. /**
  71815. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71816. */
  71817. Ellipsis = 2
  71818. }
  71819. /**
  71820. * Class used to create text block control
  71821. */
  71822. export class TextBlock extends Control {
  71823. /**
  71824. * Defines the name of the control
  71825. */
  71826. name?: string | undefined;
  71827. private _text;
  71828. private _textWrapping;
  71829. private _textHorizontalAlignment;
  71830. private _textVerticalAlignment;
  71831. private _lines;
  71832. private _resizeToFit;
  71833. private _lineSpacing;
  71834. private _outlineWidth;
  71835. private _outlineColor;
  71836. /**
  71837. * An event triggered after the text is changed
  71838. */
  71839. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71840. /**
  71841. * An event triggered after the text was broken up into lines
  71842. */
  71843. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71844. /**
  71845. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71846. */
  71847. get lines(): any[];
  71848. /**
  71849. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71850. */
  71851. get resizeToFit(): boolean;
  71852. /**
  71853. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71854. */
  71855. set resizeToFit(value: boolean);
  71856. /**
  71857. * Gets or sets a boolean indicating if text must be wrapped
  71858. */
  71859. get textWrapping(): TextWrapping | boolean;
  71860. /**
  71861. * Gets or sets a boolean indicating if text must be wrapped
  71862. */
  71863. set textWrapping(value: TextWrapping | boolean);
  71864. /**
  71865. * Gets or sets text to display
  71866. */
  71867. get text(): string;
  71868. /**
  71869. * Gets or sets text to display
  71870. */
  71871. set text(value: string);
  71872. /**
  71873. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71874. */
  71875. get textHorizontalAlignment(): number;
  71876. /**
  71877. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71878. */
  71879. set textHorizontalAlignment(value: number);
  71880. /**
  71881. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71882. */
  71883. get textVerticalAlignment(): number;
  71884. /**
  71885. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71886. */
  71887. set textVerticalAlignment(value: number);
  71888. /**
  71889. * Gets or sets line spacing value
  71890. */
  71891. set lineSpacing(value: string | number);
  71892. /**
  71893. * Gets or sets line spacing value
  71894. */
  71895. get lineSpacing(): string | number;
  71896. /**
  71897. * Gets or sets outlineWidth of the text to display
  71898. */
  71899. get outlineWidth(): number;
  71900. /**
  71901. * Gets or sets outlineWidth of the text to display
  71902. */
  71903. set outlineWidth(value: number);
  71904. /**
  71905. * Gets or sets outlineColor of the text to display
  71906. */
  71907. get outlineColor(): string;
  71908. /**
  71909. * Gets or sets outlineColor of the text to display
  71910. */
  71911. set outlineColor(value: string);
  71912. /**
  71913. * Creates a new TextBlock object
  71914. * @param name defines the name of the control
  71915. * @param text defines the text to display (emptry string by default)
  71916. */
  71917. constructor(
  71918. /**
  71919. * Defines the name of the control
  71920. */
  71921. name?: string | undefined, text?: string);
  71922. protected _getTypeName(): string;
  71923. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71924. private _drawText;
  71925. /** @hidden */
  71926. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71927. protected _applyStates(context: CanvasRenderingContext2D): void;
  71928. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71929. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71930. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71931. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71932. protected _renderLines(context: CanvasRenderingContext2D): void;
  71933. /**
  71934. * Given a width constraint applied on the text block, find the expected height
  71935. * @returns expected height
  71936. */
  71937. computeExpectedHeight(): number;
  71938. dispose(): void;
  71939. }
  71940. }
  71941. declare module BABYLON.GUI {
  71942. /**
  71943. * Class used to create 2D images
  71944. */
  71945. export class Image extends Control {
  71946. name?: string | undefined;
  71947. private _workingCanvas;
  71948. private _domImage;
  71949. private _imageWidth;
  71950. private _imageHeight;
  71951. private _loaded;
  71952. private _stretch;
  71953. private _source;
  71954. private _autoScale;
  71955. private _sourceLeft;
  71956. private _sourceTop;
  71957. private _sourceWidth;
  71958. private _sourceHeight;
  71959. private _svgAttributesComputationCompleted;
  71960. private _isSVG;
  71961. private _cellWidth;
  71962. private _cellHeight;
  71963. private _cellId;
  71964. private _populateNinePatchSlicesFromImage;
  71965. private _sliceLeft;
  71966. private _sliceRight;
  71967. private _sliceTop;
  71968. private _sliceBottom;
  71969. private _detectPointerOnOpaqueOnly;
  71970. /**
  71971. * BABYLON.Observable notified when the content is loaded
  71972. */
  71973. onImageLoadedObservable: BABYLON.Observable<Image>;
  71974. /**
  71975. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71976. */
  71977. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71978. /**
  71979. * Gets a boolean indicating that the content is loaded
  71980. */
  71981. get isLoaded(): boolean;
  71982. /**
  71983. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71984. */
  71985. get populateNinePatchSlicesFromImage(): boolean;
  71986. set populateNinePatchSlicesFromImage(value: boolean);
  71987. /**
  71988. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71989. * Beware using this as this will comsume more memory as the image has to be stored twice
  71990. */
  71991. get detectPointerOnOpaqueOnly(): boolean;
  71992. set detectPointerOnOpaqueOnly(value: boolean);
  71993. /**
  71994. * Gets or sets the left value for slicing (9-patch)
  71995. */
  71996. get sliceLeft(): number;
  71997. set sliceLeft(value: number);
  71998. /**
  71999. * Gets or sets the right value for slicing (9-patch)
  72000. */
  72001. get sliceRight(): number;
  72002. set sliceRight(value: number);
  72003. /**
  72004. * Gets or sets the top value for slicing (9-patch)
  72005. */
  72006. get sliceTop(): number;
  72007. set sliceTop(value: number);
  72008. /**
  72009. * Gets or sets the bottom value for slicing (9-patch)
  72010. */
  72011. get sliceBottom(): number;
  72012. set sliceBottom(value: number);
  72013. /**
  72014. * Gets or sets the left coordinate in the source image
  72015. */
  72016. get sourceLeft(): number;
  72017. set sourceLeft(value: number);
  72018. /**
  72019. * Gets or sets the top coordinate in the source image
  72020. */
  72021. get sourceTop(): number;
  72022. set sourceTop(value: number);
  72023. /**
  72024. * Gets or sets the width to capture in the source image
  72025. */
  72026. get sourceWidth(): number;
  72027. set sourceWidth(value: number);
  72028. /**
  72029. * Gets or sets the height to capture in the source image
  72030. */
  72031. get sourceHeight(): number;
  72032. set sourceHeight(value: number);
  72033. /** Indicates if the format of the image is SVG */
  72034. get isSVG(): boolean;
  72035. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72036. get svgAttributesComputationCompleted(): boolean;
  72037. /**
  72038. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72039. * @see http://doc.babylonjs.com/how_to/gui#image
  72040. */
  72041. get autoScale(): boolean;
  72042. set autoScale(value: boolean);
  72043. /** Gets or sets the streching mode used by the image */
  72044. get stretch(): number;
  72045. set stretch(value: number);
  72046. /** @hidden */
  72047. _rotate90(n: number, preserveProperties?: boolean): Image;
  72048. private _handleRotationForSVGImage;
  72049. private _rotate90SourceProperties;
  72050. /**
  72051. * Gets or sets the internal DOM image used to render the control
  72052. */
  72053. set domImage(value: HTMLImageElement);
  72054. get domImage(): HTMLImageElement;
  72055. private _onImageLoaded;
  72056. private _extractNinePatchSliceDataFromImage;
  72057. /**
  72058. * Gets or sets image source url
  72059. */
  72060. set source(value: BABYLON.Nullable<string>);
  72061. /**
  72062. * Checks for svg document with icon id present
  72063. */
  72064. private _svgCheck;
  72065. /**
  72066. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72067. * given external svg file and icon id
  72068. */
  72069. private _getSVGAttribs;
  72070. /**
  72071. * Gets or sets the cell width to use when animation sheet is enabled
  72072. * @see http://doc.babylonjs.com/how_to/gui#image
  72073. */
  72074. get cellWidth(): number;
  72075. set cellWidth(value: number);
  72076. /**
  72077. * Gets or sets the cell height to use when animation sheet is enabled
  72078. * @see http://doc.babylonjs.com/how_to/gui#image
  72079. */
  72080. get cellHeight(): number;
  72081. set cellHeight(value: number);
  72082. /**
  72083. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72084. * @see http://doc.babylonjs.com/how_to/gui#image
  72085. */
  72086. get cellId(): number;
  72087. set cellId(value: number);
  72088. /**
  72089. * Creates a new Image
  72090. * @param name defines the control name
  72091. * @param url defines the image url
  72092. */
  72093. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72094. /**
  72095. * Tests if a given coordinates belong to the current control
  72096. * @param x defines x coordinate to test
  72097. * @param y defines y coordinate to test
  72098. * @returns true if the coordinates are inside the control
  72099. */
  72100. contains(x: number, y: number): boolean;
  72101. protected _getTypeName(): string;
  72102. /** Force the control to synchronize with its content */
  72103. synchronizeSizeWithContent(): void;
  72104. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72105. private _prepareWorkingCanvasForOpaqueDetection;
  72106. private _drawImage;
  72107. _draw(context: CanvasRenderingContext2D): void;
  72108. private _renderCornerPatch;
  72109. private _renderNinePatch;
  72110. dispose(): void;
  72111. /** STRETCH_NONE */
  72112. static readonly STRETCH_NONE: number;
  72113. /** STRETCH_FILL */
  72114. static readonly STRETCH_FILL: number;
  72115. /** STRETCH_UNIFORM */
  72116. static readonly STRETCH_UNIFORM: number;
  72117. /** STRETCH_EXTEND */
  72118. static readonly STRETCH_EXTEND: number;
  72119. /** NINE_PATCH */
  72120. static readonly STRETCH_NINE_PATCH: number;
  72121. }
  72122. }
  72123. declare module BABYLON.GUI {
  72124. /**
  72125. * Class used to create 2D buttons
  72126. */
  72127. export class Button extends Rectangle {
  72128. name?: string | undefined;
  72129. /**
  72130. * Function called to generate a pointer enter animation
  72131. */
  72132. pointerEnterAnimation: () => void;
  72133. /**
  72134. * Function called to generate a pointer out animation
  72135. */
  72136. pointerOutAnimation: () => void;
  72137. /**
  72138. * Function called to generate a pointer down animation
  72139. */
  72140. pointerDownAnimation: () => void;
  72141. /**
  72142. * Function called to generate a pointer up animation
  72143. */
  72144. pointerUpAnimation: () => void;
  72145. /**
  72146. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72147. */
  72148. delegatePickingToChildren: boolean;
  72149. private _image;
  72150. /**
  72151. * Returns the image part of the button (if any)
  72152. */
  72153. get image(): BABYLON.Nullable<Image>;
  72154. private _textBlock;
  72155. /**
  72156. * Returns the image part of the button (if any)
  72157. */
  72158. get textBlock(): BABYLON.Nullable<TextBlock>;
  72159. /**
  72160. * Creates a new Button
  72161. * @param name defines the name of the button
  72162. */
  72163. constructor(name?: string | undefined);
  72164. protected _getTypeName(): string;
  72165. /** @hidden */
  72166. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72167. /** @hidden */
  72168. _onPointerEnter(target: Control): boolean;
  72169. /** @hidden */
  72170. _onPointerOut(target: Control, force?: boolean): void;
  72171. /** @hidden */
  72172. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72173. /** @hidden */
  72174. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72175. /**
  72176. * Creates a new button made with an image and a text
  72177. * @param name defines the name of the button
  72178. * @param text defines the text of the button
  72179. * @param imageUrl defines the url of the image
  72180. * @returns a new Button
  72181. */
  72182. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72183. /**
  72184. * Creates a new button made with an image
  72185. * @param name defines the name of the button
  72186. * @param imageUrl defines the url of the image
  72187. * @returns a new Button
  72188. */
  72189. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72190. /**
  72191. * Creates a new button made with a text
  72192. * @param name defines the name of the button
  72193. * @param text defines the text of the button
  72194. * @returns a new Button
  72195. */
  72196. static CreateSimpleButton(name: string, text: string): Button;
  72197. /**
  72198. * Creates a new button made with an image and a centered text
  72199. * @param name defines the name of the button
  72200. * @param text defines the text of the button
  72201. * @param imageUrl defines the url of the image
  72202. * @returns a new Button
  72203. */
  72204. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72205. }
  72206. }
  72207. declare module BABYLON.GUI {
  72208. /**
  72209. * Class used to create a 2D stack panel container
  72210. */
  72211. export class StackPanel extends Container {
  72212. name?: string | undefined;
  72213. private _isVertical;
  72214. private _manualWidth;
  72215. private _manualHeight;
  72216. private _doNotTrackManualChanges;
  72217. /**
  72218. * Gets or sets a boolean indicating that layou warnings should be ignored
  72219. */
  72220. ignoreLayoutWarnings: boolean;
  72221. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72222. get isVertical(): boolean;
  72223. set isVertical(value: boolean);
  72224. /**
  72225. * Gets or sets panel width.
  72226. * This value should not be set when in horizontal mode as it will be computed automatically
  72227. */
  72228. set width(value: string | number);
  72229. get width(): string | number;
  72230. /**
  72231. * Gets or sets panel height.
  72232. * This value should not be set when in vertical mode as it will be computed automatically
  72233. */
  72234. set height(value: string | number);
  72235. get height(): string | number;
  72236. /**
  72237. * Creates a new StackPanel
  72238. * @param name defines control name
  72239. */
  72240. constructor(name?: string | undefined);
  72241. protected _getTypeName(): string;
  72242. /** @hidden */
  72243. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72244. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72245. protected _postMeasure(): void;
  72246. }
  72247. }
  72248. declare module BABYLON.GUI {
  72249. /**
  72250. * Class used to represent a 2D checkbox
  72251. */
  72252. export class Checkbox extends Control {
  72253. name?: string | undefined;
  72254. private _isChecked;
  72255. private _background;
  72256. private _checkSizeRatio;
  72257. private _thickness;
  72258. /** Gets or sets border thickness */
  72259. get thickness(): number;
  72260. set thickness(value: number);
  72261. /**
  72262. * BABYLON.Observable raised when isChecked property changes
  72263. */
  72264. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72265. /** Gets or sets a value indicating the ratio between overall size and check size */
  72266. get checkSizeRatio(): number;
  72267. set checkSizeRatio(value: number);
  72268. /** Gets or sets background color */
  72269. get background(): string;
  72270. set background(value: string);
  72271. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72272. get isChecked(): boolean;
  72273. set isChecked(value: boolean);
  72274. /**
  72275. * Creates a new CheckBox
  72276. * @param name defines the control name
  72277. */
  72278. constructor(name?: string | undefined);
  72279. protected _getTypeName(): string;
  72280. /** @hidden */
  72281. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72282. /** @hidden */
  72283. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72284. /**
  72285. * Utility function to easily create a checkbox with a header
  72286. * @param title defines the label to use for the header
  72287. * @param onValueChanged defines the callback to call when value changes
  72288. * @returns a StackPanel containing the checkbox and a textBlock
  72289. */
  72290. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72291. }
  72292. }
  72293. declare module BABYLON.GUI {
  72294. /**
  72295. * Class used to store key control properties
  72296. */
  72297. export class KeyPropertySet {
  72298. /** Width */
  72299. width?: string;
  72300. /** Height */
  72301. height?: string;
  72302. /** Left padding */
  72303. paddingLeft?: string;
  72304. /** Right padding */
  72305. paddingRight?: string;
  72306. /** Top padding */
  72307. paddingTop?: string;
  72308. /** Bottom padding */
  72309. paddingBottom?: string;
  72310. /** Foreground color */
  72311. color?: string;
  72312. /** Background color */
  72313. background?: string;
  72314. }
  72315. /**
  72316. * Class used to create virtual keyboard
  72317. */
  72318. export class VirtualKeyboard extends StackPanel {
  72319. /** BABYLON.Observable raised when a key is pressed */
  72320. onKeyPressObservable: BABYLON.Observable<string>;
  72321. /** Gets or sets default key button width */
  72322. defaultButtonWidth: string;
  72323. /** Gets or sets default key button height */
  72324. defaultButtonHeight: string;
  72325. /** Gets or sets default key button left padding */
  72326. defaultButtonPaddingLeft: string;
  72327. /** Gets or sets default key button right padding */
  72328. defaultButtonPaddingRight: string;
  72329. /** Gets or sets default key button top padding */
  72330. defaultButtonPaddingTop: string;
  72331. /** Gets or sets default key button bottom padding */
  72332. defaultButtonPaddingBottom: string;
  72333. /** Gets or sets default key button foreground color */
  72334. defaultButtonColor: string;
  72335. /** Gets or sets default key button background color */
  72336. defaultButtonBackground: string;
  72337. /** Gets or sets shift button foreground color */
  72338. shiftButtonColor: string;
  72339. /** Gets or sets shift button thickness*/
  72340. selectedShiftThickness: number;
  72341. /** Gets shift key state */
  72342. shiftState: number;
  72343. protected _getTypeName(): string;
  72344. private _createKey;
  72345. /**
  72346. * Adds a new row of keys
  72347. * @param keys defines the list of keys to add
  72348. * @param propertySets defines the associated property sets
  72349. */
  72350. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72351. /**
  72352. * Set the shift key to a specific state
  72353. * @param shiftState defines the new shift state
  72354. */
  72355. applyShiftState(shiftState: number): void;
  72356. private _currentlyConnectedInputText;
  72357. private _connectedInputTexts;
  72358. private _onKeyPressObserver;
  72359. /** Gets the input text control currently attached to the keyboard */
  72360. get connectedInputText(): BABYLON.Nullable<InputText>;
  72361. /**
  72362. * Connects the keyboard with an input text control
  72363. *
  72364. * @param input defines the target control
  72365. */
  72366. connect(input: InputText): void;
  72367. /**
  72368. * Disconnects the keyboard from connected InputText controls
  72369. *
  72370. * @param input optionally defines a target control, otherwise all are disconnected
  72371. */
  72372. disconnect(input?: InputText): void;
  72373. private _removeConnectedInputObservables;
  72374. /**
  72375. * Release all resources
  72376. */
  72377. dispose(): void;
  72378. /**
  72379. * Creates a new keyboard using a default layout
  72380. *
  72381. * @param name defines control name
  72382. * @returns a new VirtualKeyboard
  72383. */
  72384. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72385. }
  72386. }
  72387. declare module BABYLON.GUI {
  72388. /**
  72389. * Class used to create input text control
  72390. */
  72391. export class InputText extends Control implements IFocusableControl {
  72392. name?: string | undefined;
  72393. private _text;
  72394. private _placeholderText;
  72395. private _background;
  72396. private _focusedBackground;
  72397. private _focusedColor;
  72398. private _placeholderColor;
  72399. private _thickness;
  72400. private _margin;
  72401. private _autoStretchWidth;
  72402. private _maxWidth;
  72403. private _isFocused;
  72404. private _blinkTimeout;
  72405. private _blinkIsEven;
  72406. private _cursorOffset;
  72407. private _scrollLeft;
  72408. private _textWidth;
  72409. private _clickedCoordinate;
  72410. private _deadKey;
  72411. private _addKey;
  72412. private _currentKey;
  72413. private _isTextHighlightOn;
  72414. private _textHighlightColor;
  72415. private _highligherOpacity;
  72416. private _highlightedText;
  72417. private _startHighlightIndex;
  72418. private _endHighlightIndex;
  72419. private _cursorIndex;
  72420. private _onFocusSelectAll;
  72421. private _isPointerDown;
  72422. private _onClipboardObserver;
  72423. private _onPointerDblTapObserver;
  72424. /** @hidden */
  72425. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72426. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72427. promptMessage: string;
  72428. /** Force disable prompt on mobile device */
  72429. disableMobilePrompt: boolean;
  72430. /** BABYLON.Observable raised when the text changes */
  72431. onTextChangedObservable: BABYLON.Observable<InputText>;
  72432. /** BABYLON.Observable raised just before an entered character is to be added */
  72433. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72434. /** BABYLON.Observable raised when the control gets the focus */
  72435. onFocusObservable: BABYLON.Observable<InputText>;
  72436. /** BABYLON.Observable raised when the control loses the focus */
  72437. onBlurObservable: BABYLON.Observable<InputText>;
  72438. /**Observable raised when the text is highlighted */
  72439. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72440. /**Observable raised when copy event is triggered */
  72441. onTextCopyObservable: BABYLON.Observable<InputText>;
  72442. /** BABYLON.Observable raised when cut event is triggered */
  72443. onTextCutObservable: BABYLON.Observable<InputText>;
  72444. /** BABYLON.Observable raised when paste event is triggered */
  72445. onTextPasteObservable: BABYLON.Observable<InputText>;
  72446. /** BABYLON.Observable raised when a key event was processed */
  72447. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72448. /** Gets or sets the maximum width allowed by the control */
  72449. get maxWidth(): string | number;
  72450. /** Gets the maximum width allowed by the control in pixels */
  72451. get maxWidthInPixels(): number;
  72452. set maxWidth(value: string | number);
  72453. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72454. get highligherOpacity(): number;
  72455. set highligherOpacity(value: number);
  72456. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72457. get onFocusSelectAll(): boolean;
  72458. set onFocusSelectAll(value: boolean);
  72459. /** Gets or sets the text hightlight color */
  72460. get textHighlightColor(): string;
  72461. set textHighlightColor(value: string);
  72462. /** Gets or sets control margin */
  72463. get margin(): string;
  72464. /** Gets control margin in pixels */
  72465. get marginInPixels(): number;
  72466. set margin(value: string);
  72467. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72468. get autoStretchWidth(): boolean;
  72469. set autoStretchWidth(value: boolean);
  72470. /** Gets or sets border thickness */
  72471. get thickness(): number;
  72472. set thickness(value: number);
  72473. /** Gets or sets the background color when focused */
  72474. get focusedBackground(): string;
  72475. set focusedBackground(value: string);
  72476. /** Gets or sets the background color when focused */
  72477. get focusedColor(): string;
  72478. set focusedColor(value: string);
  72479. /** Gets or sets the background color */
  72480. get background(): string;
  72481. set background(value: string);
  72482. /** Gets or sets the placeholder color */
  72483. get placeholderColor(): string;
  72484. set placeholderColor(value: string);
  72485. /** Gets or sets the text displayed when the control is empty */
  72486. get placeholderText(): string;
  72487. set placeholderText(value: string);
  72488. /** Gets or sets the dead key flag */
  72489. get deadKey(): boolean;
  72490. set deadKey(flag: boolean);
  72491. /** Gets or sets the highlight text */
  72492. get highlightedText(): string;
  72493. set highlightedText(text: string);
  72494. /** Gets or sets if the current key should be added */
  72495. get addKey(): boolean;
  72496. set addKey(flag: boolean);
  72497. /** Gets or sets the value of the current key being entered */
  72498. get currentKey(): string;
  72499. set currentKey(key: string);
  72500. /** Gets or sets the text displayed in the control */
  72501. get text(): string;
  72502. set text(value: string);
  72503. /** Gets or sets control width */
  72504. get width(): string | number;
  72505. set width(value: string | number);
  72506. /**
  72507. * Creates a new InputText
  72508. * @param name defines the control name
  72509. * @param text defines the text of the control
  72510. */
  72511. constructor(name?: string | undefined, text?: string);
  72512. /** @hidden */
  72513. onBlur(): void;
  72514. /** @hidden */
  72515. onFocus(): void;
  72516. protected _getTypeName(): string;
  72517. /**
  72518. * Function called to get the list of controls that should not steal the focus from this control
  72519. * @returns an array of controls
  72520. */
  72521. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72522. /** @hidden */
  72523. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72524. /** @hidden */
  72525. private _updateValueFromCursorIndex;
  72526. /** @hidden */
  72527. private _processDblClick;
  72528. /** @hidden */
  72529. private _selectAllText;
  72530. /**
  72531. * Handles the keyboard event
  72532. * @param evt Defines the KeyboardEvent
  72533. */
  72534. processKeyboard(evt: KeyboardEvent): void;
  72535. /** @hidden */
  72536. private _onCopyText;
  72537. /** @hidden */
  72538. private _onCutText;
  72539. /** @hidden */
  72540. private _onPasteText;
  72541. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72542. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72543. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72544. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72545. protected _beforeRenderText(text: string): string;
  72546. dispose(): void;
  72547. }
  72548. }
  72549. declare module BABYLON.GUI {
  72550. /**
  72551. * Class used to create a 2D grid container
  72552. */
  72553. export class Grid extends Container {
  72554. name?: string | undefined;
  72555. private _rowDefinitions;
  72556. private _columnDefinitions;
  72557. private _cells;
  72558. private _childControls;
  72559. /**
  72560. * Gets the number of columns
  72561. */
  72562. get columnCount(): number;
  72563. /**
  72564. * Gets the number of rows
  72565. */
  72566. get rowCount(): number;
  72567. /** Gets the list of children */
  72568. get children(): Control[];
  72569. /** Gets the list of cells (e.g. the containers) */
  72570. get cells(): {
  72571. [key: string]: Container;
  72572. };
  72573. /**
  72574. * Gets the definition of a specific row
  72575. * @param index defines the index of the row
  72576. * @returns the row definition
  72577. */
  72578. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72579. /**
  72580. * Gets the definition of a specific column
  72581. * @param index defines the index of the column
  72582. * @returns the column definition
  72583. */
  72584. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72585. /**
  72586. * Adds a new row to the grid
  72587. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72588. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72589. * @returns the current grid
  72590. */
  72591. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72592. /**
  72593. * Adds a new column to the grid
  72594. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72595. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72596. * @returns the current grid
  72597. */
  72598. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72599. /**
  72600. * Update a row definition
  72601. * @param index defines the index of the row to update
  72602. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72603. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72604. * @returns the current grid
  72605. */
  72606. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72607. /**
  72608. * Update a column definition
  72609. * @param index defines the index of the column to update
  72610. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72611. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72612. * @returns the current grid
  72613. */
  72614. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72615. /**
  72616. * Gets the list of children stored in a specific cell
  72617. * @param row defines the row to check
  72618. * @param column defines the column to check
  72619. * @returns the list of controls
  72620. */
  72621. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72622. /**
  72623. * Gets a string representing the child cell info (row x column)
  72624. * @param child defines the control to get info from
  72625. * @returns a string containing the child cell info (row x column)
  72626. */
  72627. getChildCellInfo(child: Control): string;
  72628. private _removeCell;
  72629. private _offsetCell;
  72630. /**
  72631. * Remove a column definition at specified index
  72632. * @param index defines the index of the column to remove
  72633. * @returns the current grid
  72634. */
  72635. removeColumnDefinition(index: number): Grid;
  72636. /**
  72637. * Remove a row definition at specified index
  72638. * @param index defines the index of the row to remove
  72639. * @returns the current grid
  72640. */
  72641. removeRowDefinition(index: number): Grid;
  72642. /**
  72643. * Adds a new control to the current grid
  72644. * @param control defines the control to add
  72645. * @param row defines the row where to add the control (0 by default)
  72646. * @param column defines the column where to add the control (0 by default)
  72647. * @returns the current grid
  72648. */
  72649. addControl(control: Control, row?: number, column?: number): Grid;
  72650. /**
  72651. * Removes a control from the current container
  72652. * @param control defines the control to remove
  72653. * @returns the current container
  72654. */
  72655. removeControl(control: Control): Container;
  72656. /**
  72657. * Creates a new Grid
  72658. * @param name defines control name
  72659. */
  72660. constructor(name?: string | undefined);
  72661. protected _getTypeName(): string;
  72662. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72663. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72664. _flagDescendantsAsMatrixDirty(): void;
  72665. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72666. /** Releases associated resources */
  72667. dispose(): void;
  72668. }
  72669. }
  72670. declare module BABYLON.GUI {
  72671. /** Class used to create color pickers */
  72672. export class ColorPicker extends Control {
  72673. name?: string | undefined;
  72674. private static _Epsilon;
  72675. private _colorWheelCanvas;
  72676. private _value;
  72677. private _tmpColor;
  72678. private _pointerStartedOnSquare;
  72679. private _pointerStartedOnWheel;
  72680. private _squareLeft;
  72681. private _squareTop;
  72682. private _squareSize;
  72683. private _h;
  72684. private _s;
  72685. private _v;
  72686. private _lastPointerDownID;
  72687. /**
  72688. * BABYLON.Observable raised when the value changes
  72689. */
  72690. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72691. /** Gets or sets the color of the color picker */
  72692. get value(): BABYLON.Color3;
  72693. set value(value: BABYLON.Color3);
  72694. /**
  72695. * Gets or sets control width
  72696. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72697. */
  72698. get width(): string | number;
  72699. set width(value: string | number);
  72700. /**
  72701. * Gets or sets control height
  72702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72703. */
  72704. get height(): string | number;
  72705. /** Gets or sets control height */
  72706. set height(value: string | number);
  72707. /** Gets or sets control size */
  72708. get size(): string | number;
  72709. set size(value: string | number);
  72710. /**
  72711. * Creates a new ColorPicker
  72712. * @param name defines the control name
  72713. */
  72714. constructor(name?: string | undefined);
  72715. protected _getTypeName(): string;
  72716. /** @hidden */
  72717. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72718. private _updateSquareProps;
  72719. private _drawGradientSquare;
  72720. private _drawCircle;
  72721. private _createColorWheelCanvas;
  72722. /** @hidden */
  72723. _draw(context: CanvasRenderingContext2D): void;
  72724. private _pointerIsDown;
  72725. private _updateValueFromPointer;
  72726. private _isPointOnSquare;
  72727. private _isPointOnWheel;
  72728. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72729. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72730. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72731. /**
  72732. * This function expands the color picker by creating a color picker dialog with manual
  72733. * color value input and the ability to save colors into an array to be used later in
  72734. * subsequent launches of the dialogue.
  72735. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72736. * @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.
  72737. * @returns picked color as a hex string and the saved colors array as hex strings.
  72738. */
  72739. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72740. pickerWidth?: string;
  72741. pickerHeight?: string;
  72742. headerHeight?: string;
  72743. lastColor?: string;
  72744. swatchLimit?: number;
  72745. numSwatchesPerLine?: number;
  72746. savedColors?: Array<string>;
  72747. }): Promise<{
  72748. savedColors?: string[];
  72749. pickedColor: string;
  72750. }>;
  72751. }
  72752. }
  72753. declare module BABYLON.GUI {
  72754. /** Class used to create 2D ellipse containers */
  72755. export class Ellipse extends Container {
  72756. name?: string | undefined;
  72757. private _thickness;
  72758. /** Gets or sets border thickness */
  72759. get thickness(): number;
  72760. set thickness(value: number);
  72761. /**
  72762. * Creates a new Ellipse
  72763. * @param name defines the control name
  72764. */
  72765. constructor(name?: string | undefined);
  72766. protected _getTypeName(): string;
  72767. protected _localDraw(context: CanvasRenderingContext2D): void;
  72768. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72769. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72770. }
  72771. }
  72772. declare module BABYLON.GUI {
  72773. /**
  72774. * Class used to create a password control
  72775. */
  72776. export class InputPassword extends InputText {
  72777. protected _beforeRenderText(text: string): string;
  72778. }
  72779. }
  72780. declare module BABYLON.GUI {
  72781. /** Class used to render 2D lines */
  72782. export class Line extends Control {
  72783. name?: string | undefined;
  72784. private _lineWidth;
  72785. private _x1;
  72786. private _y1;
  72787. private _x2;
  72788. private _y2;
  72789. private _dash;
  72790. private _connectedControl;
  72791. private _connectedControlDirtyObserver;
  72792. /** Gets or sets the dash pattern */
  72793. get dash(): Array<number>;
  72794. set dash(value: Array<number>);
  72795. /** Gets or sets the control connected with the line end */
  72796. get connectedControl(): Control;
  72797. set connectedControl(value: Control);
  72798. /** Gets or sets start coordinates on X axis */
  72799. get x1(): string | number;
  72800. set x1(value: string | number);
  72801. /** Gets or sets start coordinates on Y axis */
  72802. get y1(): string | number;
  72803. set y1(value: string | number);
  72804. /** Gets or sets end coordinates on X axis */
  72805. get x2(): string | number;
  72806. set x2(value: string | number);
  72807. /** Gets or sets end coordinates on Y axis */
  72808. get y2(): string | number;
  72809. set y2(value: string | number);
  72810. /** Gets or sets line width */
  72811. get lineWidth(): number;
  72812. set lineWidth(value: number);
  72813. /** Gets or sets horizontal alignment */
  72814. set horizontalAlignment(value: number);
  72815. /** Gets or sets vertical alignment */
  72816. set verticalAlignment(value: number);
  72817. private get _effectiveX2();
  72818. private get _effectiveY2();
  72819. /**
  72820. * Creates a new Line
  72821. * @param name defines the control name
  72822. */
  72823. constructor(name?: string | undefined);
  72824. protected _getTypeName(): string;
  72825. _draw(context: CanvasRenderingContext2D): void;
  72826. _measure(): void;
  72827. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72828. /**
  72829. * Move one end of the line given 3D cartesian coordinates.
  72830. * @param position Targeted world position
  72831. * @param scene BABYLON.Scene
  72832. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72833. */
  72834. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72835. /**
  72836. * Move one end of the line to a position in screen absolute space.
  72837. * @param projectedPosition Position in screen absolute space (X, Y)
  72838. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72839. */
  72840. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72841. }
  72842. }
  72843. declare module BABYLON.GUI {
  72844. /**
  72845. * Class used to store a point for a MultiLine object.
  72846. * The point can be pure 2D coordinates, a mesh or a control
  72847. */
  72848. export class MultiLinePoint {
  72849. private _multiLine;
  72850. private _x;
  72851. private _y;
  72852. private _control;
  72853. private _mesh;
  72854. private _controlObserver;
  72855. private _meshObserver;
  72856. /** @hidden */
  72857. _point: BABYLON.Vector2;
  72858. /**
  72859. * Creates a new MultiLinePoint
  72860. * @param multiLine defines the source MultiLine object
  72861. */
  72862. constructor(multiLine: MultiLine);
  72863. /** Gets or sets x coordinate */
  72864. get x(): string | number;
  72865. set x(value: string | number);
  72866. /** Gets or sets y coordinate */
  72867. get y(): string | number;
  72868. set y(value: string | number);
  72869. /** Gets or sets the control associated with this point */
  72870. get control(): BABYLON.Nullable<Control>;
  72871. set control(value: BABYLON.Nullable<Control>);
  72872. /** Gets or sets the mesh associated with this point */
  72873. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72874. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72875. /** Resets links */
  72876. resetLinks(): void;
  72877. /**
  72878. * Gets a translation vector
  72879. * @returns the translation vector
  72880. */
  72881. translate(): BABYLON.Vector2;
  72882. private _translatePoint;
  72883. /** Release associated resources */
  72884. dispose(): void;
  72885. }
  72886. }
  72887. declare module BABYLON.GUI {
  72888. /**
  72889. * Class used to create multi line control
  72890. */
  72891. export class MultiLine extends Control {
  72892. name?: string | undefined;
  72893. private _lineWidth;
  72894. private _dash;
  72895. private _points;
  72896. private _minX;
  72897. private _minY;
  72898. private _maxX;
  72899. private _maxY;
  72900. /**
  72901. * Creates a new MultiLine
  72902. * @param name defines the control name
  72903. */
  72904. constructor(name?: string | undefined);
  72905. /** Gets or sets dash pattern */
  72906. get dash(): Array<number>;
  72907. set dash(value: Array<number>);
  72908. /**
  72909. * Gets point stored at specified index
  72910. * @param index defines the index to look for
  72911. * @returns the requested point if found
  72912. */
  72913. getAt(index: number): MultiLinePoint;
  72914. /** Function called when a point is updated */
  72915. onPointUpdate: () => void;
  72916. /**
  72917. * Adds new points to the point collection
  72918. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72919. * @returns the list of created MultiLinePoint
  72920. */
  72921. add(...items: (AbstractMesh | Control | {
  72922. x: string | number;
  72923. y: string | number;
  72924. })[]): MultiLinePoint[];
  72925. /**
  72926. * Adds a new point to the point collection
  72927. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72928. * @returns the created MultiLinePoint
  72929. */
  72930. push(item?: (AbstractMesh | Control | {
  72931. x: string | number;
  72932. y: string | number;
  72933. })): MultiLinePoint;
  72934. /**
  72935. * Remove a specific value or point from the active point collection
  72936. * @param value defines the value or point to remove
  72937. */
  72938. remove(value: number | MultiLinePoint): void;
  72939. /**
  72940. * Resets this object to initial state (no point)
  72941. */
  72942. reset(): void;
  72943. /**
  72944. * Resets all links
  72945. */
  72946. resetLinks(): void;
  72947. /** Gets or sets line width */
  72948. get lineWidth(): number;
  72949. set lineWidth(value: number);
  72950. set horizontalAlignment(value: number);
  72951. set verticalAlignment(value: number);
  72952. protected _getTypeName(): string;
  72953. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72954. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72955. _measure(): void;
  72956. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72957. dispose(): void;
  72958. }
  72959. }
  72960. declare module BABYLON.GUI {
  72961. /**
  72962. * Class used to create radio button controls
  72963. */
  72964. export class RadioButton extends Control {
  72965. name?: string | undefined;
  72966. private _isChecked;
  72967. private _background;
  72968. private _checkSizeRatio;
  72969. private _thickness;
  72970. /** Gets or sets border thickness */
  72971. get thickness(): number;
  72972. set thickness(value: number);
  72973. /** Gets or sets group name */
  72974. group: string;
  72975. /** BABYLON.Observable raised when isChecked is changed */
  72976. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72977. /** Gets or sets a value indicating the ratio between overall size and check size */
  72978. get checkSizeRatio(): number;
  72979. set checkSizeRatio(value: number);
  72980. /** Gets or sets background color */
  72981. get background(): string;
  72982. set background(value: string);
  72983. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72984. get isChecked(): boolean;
  72985. set isChecked(value: boolean);
  72986. /**
  72987. * Creates a new RadioButton
  72988. * @param name defines the control name
  72989. */
  72990. constructor(name?: string | undefined);
  72991. protected _getTypeName(): string;
  72992. _draw(context: CanvasRenderingContext2D): void;
  72993. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72994. /**
  72995. * Utility function to easily create a radio button with a header
  72996. * @param title defines the label to use for the header
  72997. * @param group defines the group to use for the radio button
  72998. * @param isChecked defines the initial state of the radio button
  72999. * @param onValueChanged defines the callback to call when value changes
  73000. * @returns a StackPanel containing the radio button and a textBlock
  73001. */
  73002. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73003. }
  73004. }
  73005. declare module BABYLON.GUI {
  73006. /**
  73007. * Class used to create slider controls
  73008. */
  73009. export class BaseSlider extends Control {
  73010. name?: string | undefined;
  73011. protected _thumbWidth: ValueAndUnit;
  73012. private _minimum;
  73013. private _maximum;
  73014. private _value;
  73015. private _isVertical;
  73016. protected _barOffset: ValueAndUnit;
  73017. private _isThumbClamped;
  73018. protected _displayThumb: boolean;
  73019. private _step;
  73020. private _lastPointerDownID;
  73021. protected _effectiveBarOffset: number;
  73022. protected _renderLeft: number;
  73023. protected _renderTop: number;
  73024. protected _renderWidth: number;
  73025. protected _renderHeight: number;
  73026. protected _backgroundBoxLength: number;
  73027. protected _backgroundBoxThickness: number;
  73028. protected _effectiveThumbThickness: number;
  73029. /** BABYLON.Observable raised when the sldier value changes */
  73030. onValueChangedObservable: BABYLON.Observable<number>;
  73031. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73032. get displayThumb(): boolean;
  73033. set displayThumb(value: boolean);
  73034. /** Gets or sets a step to apply to values (0 by default) */
  73035. get step(): number;
  73036. set step(value: number);
  73037. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73038. get barOffset(): string | number;
  73039. /** Gets main bar offset in pixels*/
  73040. get barOffsetInPixels(): number;
  73041. set barOffset(value: string | number);
  73042. /** Gets or sets thumb width */
  73043. get thumbWidth(): string | number;
  73044. /** Gets thumb width in pixels */
  73045. get thumbWidthInPixels(): number;
  73046. set thumbWidth(value: string | number);
  73047. /** Gets or sets minimum value */
  73048. get minimum(): number;
  73049. set minimum(value: number);
  73050. /** Gets or sets maximum value */
  73051. get maximum(): number;
  73052. set maximum(value: number);
  73053. /** Gets or sets current value */
  73054. get value(): number;
  73055. set value(value: number);
  73056. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73057. get isVertical(): boolean;
  73058. set isVertical(value: boolean);
  73059. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73060. get isThumbClamped(): boolean;
  73061. set isThumbClamped(value: boolean);
  73062. /**
  73063. * Creates a new BaseSlider
  73064. * @param name defines the control name
  73065. */
  73066. constructor(name?: string | undefined);
  73067. protected _getTypeName(): string;
  73068. protected _getThumbPosition(): number;
  73069. protected _getThumbThickness(type: string): number;
  73070. protected _prepareRenderingData(type: string): void;
  73071. private _pointerIsDown;
  73072. /** @hidden */
  73073. protected _updateValueFromPointer(x: number, y: number): void;
  73074. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73075. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73076. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73077. }
  73078. }
  73079. declare module BABYLON.GUI {
  73080. /**
  73081. * Class used to create slider controls
  73082. */
  73083. export class Slider extends BaseSlider {
  73084. name?: string | undefined;
  73085. private _background;
  73086. private _borderColor;
  73087. private _isThumbCircle;
  73088. protected _displayValueBar: boolean;
  73089. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73090. get displayValueBar(): boolean;
  73091. set displayValueBar(value: boolean);
  73092. /** Gets or sets border color */
  73093. get borderColor(): string;
  73094. set borderColor(value: string);
  73095. /** Gets or sets background color */
  73096. get background(): string;
  73097. set background(value: string);
  73098. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73099. get isThumbCircle(): boolean;
  73100. set isThumbCircle(value: boolean);
  73101. /**
  73102. * Creates a new Slider
  73103. * @param name defines the control name
  73104. */
  73105. constructor(name?: string | undefined);
  73106. protected _getTypeName(): string;
  73107. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73108. }
  73109. }
  73110. declare module BABYLON.GUI {
  73111. /** Class used to create a RadioGroup
  73112. * which contains groups of radio buttons
  73113. */
  73114. export class SelectorGroup {
  73115. /** name of SelectorGroup */
  73116. name: string;
  73117. private _groupPanel;
  73118. private _selectors;
  73119. private _groupHeader;
  73120. /**
  73121. * Creates a new SelectorGroup
  73122. * @param name of group, used as a group heading
  73123. */
  73124. constructor(
  73125. /** name of SelectorGroup */
  73126. name: string);
  73127. /** Gets the groupPanel of the SelectorGroup */
  73128. get groupPanel(): StackPanel;
  73129. /** Gets the selectors array */
  73130. get selectors(): StackPanel[];
  73131. /** Gets and sets the group header */
  73132. get header(): string;
  73133. set header(label: string);
  73134. /** @hidden */
  73135. private _addGroupHeader;
  73136. /** @hidden*/
  73137. _getSelector(selectorNb: number): StackPanel | undefined;
  73138. /** Removes the selector at the given position
  73139. * @param selectorNb the position of the selector within the group
  73140. */
  73141. removeSelector(selectorNb: number): void;
  73142. }
  73143. /** Class used to create a CheckboxGroup
  73144. * which contains groups of checkbox buttons
  73145. */
  73146. export class CheckboxGroup extends SelectorGroup {
  73147. /** Adds a checkbox as a control
  73148. * @param text is the label for the selector
  73149. * @param func is the function called when the Selector is checked
  73150. * @param checked is true when Selector is checked
  73151. */
  73152. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73153. /** @hidden */
  73154. _setSelectorLabel(selectorNb: number, label: string): void;
  73155. /** @hidden */
  73156. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73157. /** @hidden */
  73158. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73159. /** @hidden */
  73160. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73161. }
  73162. /** Class used to create a RadioGroup
  73163. * which contains groups of radio buttons
  73164. */
  73165. export class RadioGroup extends SelectorGroup {
  73166. private _selectNb;
  73167. /** Adds a radio button as a control
  73168. * @param label is the label for the selector
  73169. * @param func is the function called when the Selector is checked
  73170. * @param checked is true when Selector is checked
  73171. */
  73172. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73173. /** @hidden */
  73174. _setSelectorLabel(selectorNb: number, label: string): void;
  73175. /** @hidden */
  73176. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73177. /** @hidden */
  73178. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73179. /** @hidden */
  73180. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73181. }
  73182. /** Class used to create a SliderGroup
  73183. * which contains groups of slider buttons
  73184. */
  73185. export class SliderGroup extends SelectorGroup {
  73186. /**
  73187. * Adds a slider to the SelectorGroup
  73188. * @param label is the label for the SliderBar
  73189. * @param func is the function called when the Slider moves
  73190. * @param unit is a string describing the units used, eg degrees or metres
  73191. * @param min is the minimum value for the Slider
  73192. * @param max is the maximum value for the Slider
  73193. * @param value is the start value for the Slider between min and max
  73194. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73195. */
  73196. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73197. /** @hidden */
  73198. _setSelectorLabel(selectorNb: number, label: string): void;
  73199. /** @hidden */
  73200. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73201. /** @hidden */
  73202. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73203. /** @hidden */
  73204. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73205. }
  73206. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73207. * @see http://doc.babylonjs.com/how_to/selector
  73208. */
  73209. export class SelectionPanel extends Rectangle {
  73210. /** name of SelectionPanel */
  73211. name: string;
  73212. /** an array of SelectionGroups */
  73213. groups: SelectorGroup[];
  73214. private _panel;
  73215. private _buttonColor;
  73216. private _buttonBackground;
  73217. private _headerColor;
  73218. private _barColor;
  73219. private _barHeight;
  73220. private _spacerHeight;
  73221. private _labelColor;
  73222. private _groups;
  73223. private _bars;
  73224. /**
  73225. * Creates a new SelectionPanel
  73226. * @param name of SelectionPanel
  73227. * @param groups is an array of SelectionGroups
  73228. */
  73229. constructor(
  73230. /** name of SelectionPanel */
  73231. name: string,
  73232. /** an array of SelectionGroups */
  73233. groups?: SelectorGroup[]);
  73234. protected _getTypeName(): string;
  73235. /** Gets or sets the headerColor */
  73236. get headerColor(): string;
  73237. set headerColor(color: string);
  73238. private _setHeaderColor;
  73239. /** Gets or sets the button color */
  73240. get buttonColor(): string;
  73241. set buttonColor(color: string);
  73242. private _setbuttonColor;
  73243. /** Gets or sets the label color */
  73244. get labelColor(): string;
  73245. set labelColor(color: string);
  73246. private _setLabelColor;
  73247. /** Gets or sets the button background */
  73248. get buttonBackground(): string;
  73249. set buttonBackground(color: string);
  73250. private _setButtonBackground;
  73251. /** Gets or sets the color of separator bar */
  73252. get barColor(): string;
  73253. set barColor(color: string);
  73254. private _setBarColor;
  73255. /** Gets or sets the height of separator bar */
  73256. get barHeight(): string;
  73257. set barHeight(value: string);
  73258. private _setBarHeight;
  73259. /** Gets or sets the height of spacers*/
  73260. get spacerHeight(): string;
  73261. set spacerHeight(value: string);
  73262. private _setSpacerHeight;
  73263. /** Adds a bar between groups */
  73264. private _addSpacer;
  73265. /** Add a group to the selection panel
  73266. * @param group is the selector group to add
  73267. */
  73268. addGroup(group: SelectorGroup): void;
  73269. /** Remove the group from the given position
  73270. * @param groupNb is the position of the group in the list
  73271. */
  73272. removeGroup(groupNb: number): void;
  73273. /** Change a group header label
  73274. * @param label is the new group header label
  73275. * @param groupNb is the number of the group to relabel
  73276. * */
  73277. setHeaderName(label: string, groupNb: number): void;
  73278. /** Change selector label to the one given
  73279. * @param label is the new selector label
  73280. * @param groupNb is the number of the groupcontaining the selector
  73281. * @param selectorNb is the number of the selector within a group to relabel
  73282. * */
  73283. relabel(label: string, groupNb: number, selectorNb: number): void;
  73284. /** For a given group position remove the selector at the given position
  73285. * @param groupNb is the number of the group to remove the selector from
  73286. * @param selectorNb is the number of the selector within the group
  73287. */
  73288. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73289. /** For a given group position of correct type add a checkbox button
  73290. * @param groupNb is the number of the group to remove the selector from
  73291. * @param label is the label for the selector
  73292. * @param func is the function called when the Selector is checked
  73293. * @param checked is true when Selector is checked
  73294. */
  73295. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73296. /** For a given group position of correct type add a radio button
  73297. * @param groupNb is the number of the group to remove the selector from
  73298. * @param label is the label for the selector
  73299. * @param func is the function called when the Selector is checked
  73300. * @param checked is true when Selector is checked
  73301. */
  73302. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73303. /**
  73304. * For a given slider group add a slider
  73305. * @param groupNb is the number of the group to add the slider to
  73306. * @param label is the label for the Slider
  73307. * @param func is the function called when the Slider moves
  73308. * @param unit is a string describing the units used, eg degrees or metres
  73309. * @param min is the minimum value for the Slider
  73310. * @param max is the maximum value for the Slider
  73311. * @param value is the start value for the Slider between min and max
  73312. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73313. */
  73314. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73315. }
  73316. }
  73317. declare module BABYLON.GUI {
  73318. /**
  73319. * Class used to hold a the container for ScrollViewer
  73320. * @hidden
  73321. */
  73322. export class _ScrollViewerWindow extends Container {
  73323. parentClientWidth: number;
  73324. parentClientHeight: number;
  73325. private _freezeControls;
  73326. private _parentMeasure;
  73327. private _oldLeft;
  73328. private _oldTop;
  73329. get freezeControls(): boolean;
  73330. set freezeControls(value: boolean);
  73331. private _bucketWidth;
  73332. private _bucketHeight;
  73333. private _buckets;
  73334. private _bucketLen;
  73335. get bucketWidth(): number;
  73336. get bucketHeight(): number;
  73337. setBucketSizes(width: number, height: number): void;
  73338. private _useBuckets;
  73339. private _makeBuckets;
  73340. private _dispatchInBuckets;
  73341. private _updateMeasures;
  73342. private _updateChildrenMeasures;
  73343. private _restoreMeasures;
  73344. /**
  73345. * Creates a new ScrollViewerWindow
  73346. * @param name of ScrollViewerWindow
  73347. */
  73348. constructor(name?: string);
  73349. protected _getTypeName(): string;
  73350. /** @hidden */
  73351. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73352. /** @hidden */
  73353. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73354. private _scrollChildren;
  73355. private _scrollChildrenWithBuckets;
  73356. /** @hidden */
  73357. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73358. protected _postMeasure(): void;
  73359. }
  73360. }
  73361. declare module BABYLON.GUI {
  73362. /**
  73363. * Class used to create slider controls
  73364. */
  73365. export class ScrollBar extends BaseSlider {
  73366. name?: string | undefined;
  73367. private _background;
  73368. private _borderColor;
  73369. private _tempMeasure;
  73370. /** Gets or sets border color */
  73371. get borderColor(): string;
  73372. set borderColor(value: string);
  73373. /** Gets or sets background color */
  73374. get background(): string;
  73375. set background(value: string);
  73376. /**
  73377. * Creates a new Slider
  73378. * @param name defines the control name
  73379. */
  73380. constructor(name?: string | undefined);
  73381. protected _getTypeName(): string;
  73382. protected _getThumbThickness(): number;
  73383. _draw(context: CanvasRenderingContext2D): void;
  73384. private _first;
  73385. private _originX;
  73386. private _originY;
  73387. /** @hidden */
  73388. protected _updateValueFromPointer(x: number, y: number): void;
  73389. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73390. }
  73391. }
  73392. declare module BABYLON.GUI {
  73393. /**
  73394. * Class used to create slider controls
  73395. */
  73396. export class ImageScrollBar extends BaseSlider {
  73397. name?: string | undefined;
  73398. private _backgroundBaseImage;
  73399. private _backgroundImage;
  73400. private _thumbImage;
  73401. private _thumbBaseImage;
  73402. private _thumbLength;
  73403. private _thumbHeight;
  73404. private _barImageHeight;
  73405. private _tempMeasure;
  73406. /** Number of 90° rotation to apply on the images when in vertical mode */
  73407. num90RotationInVerticalMode: number;
  73408. /**
  73409. * Gets or sets the image used to render the background for horizontal bar
  73410. */
  73411. get backgroundImage(): Image;
  73412. set backgroundImage(value: Image);
  73413. /**
  73414. * Gets or sets the image used to render the thumb
  73415. */
  73416. get thumbImage(): Image;
  73417. set thumbImage(value: Image);
  73418. /**
  73419. * Gets or sets the length of the thumb
  73420. */
  73421. get thumbLength(): number;
  73422. set thumbLength(value: number);
  73423. /**
  73424. * Gets or sets the height of the thumb
  73425. */
  73426. get thumbHeight(): number;
  73427. set thumbHeight(value: number);
  73428. /**
  73429. * Gets or sets the height of the bar image
  73430. */
  73431. get barImageHeight(): number;
  73432. set barImageHeight(value: number);
  73433. /**
  73434. * Creates a new ImageScrollBar
  73435. * @param name defines the control name
  73436. */
  73437. constructor(name?: string | undefined);
  73438. protected _getTypeName(): string;
  73439. protected _getThumbThickness(): number;
  73440. _draw(context: CanvasRenderingContext2D): void;
  73441. private _first;
  73442. private _originX;
  73443. private _originY;
  73444. /** @hidden */
  73445. protected _updateValueFromPointer(x: number, y: number): void;
  73446. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73447. }
  73448. }
  73449. declare module BABYLON.GUI {
  73450. /**
  73451. * Class used to hold a viewer window and sliders in a grid
  73452. */
  73453. export class ScrollViewer extends Rectangle {
  73454. private _grid;
  73455. private _horizontalBarSpace;
  73456. private _verticalBarSpace;
  73457. private _dragSpace;
  73458. private _horizontalBar;
  73459. private _verticalBar;
  73460. private _barColor;
  73461. private _barBackground;
  73462. private _barImage;
  73463. private _horizontalBarImage;
  73464. private _verticalBarImage;
  73465. private _barBackgroundImage;
  73466. private _horizontalBarBackgroundImage;
  73467. private _verticalBarBackgroundImage;
  73468. private _barSize;
  73469. private _window;
  73470. private _pointerIsOver;
  73471. private _wheelPrecision;
  73472. private _onWheelObserver;
  73473. private _clientWidth;
  73474. private _clientHeight;
  73475. private _useImageBar;
  73476. private _thumbLength;
  73477. private _thumbHeight;
  73478. private _barImageHeight;
  73479. private _horizontalBarImageHeight;
  73480. private _verticalBarImageHeight;
  73481. /**
  73482. * Gets the horizontal scrollbar
  73483. */
  73484. get horizontalBar(): ScrollBar | ImageScrollBar;
  73485. /**
  73486. * Gets the vertical scrollbar
  73487. */
  73488. get verticalBar(): ScrollBar | ImageScrollBar;
  73489. /**
  73490. * Adds a new control to the current container
  73491. * @param control defines the control to add
  73492. * @returns the current container
  73493. */
  73494. addControl(control: BABYLON.Nullable<Control>): Container;
  73495. /**
  73496. * Removes a control from the current container
  73497. * @param control defines the control to remove
  73498. * @returns the current container
  73499. */
  73500. removeControl(control: Control): Container;
  73501. /** Gets the list of children */
  73502. get children(): Control[];
  73503. _flagDescendantsAsMatrixDirty(): void;
  73504. /**
  73505. * Freezes or unfreezes the controls in the window.
  73506. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73507. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73508. */
  73509. get freezeControls(): boolean;
  73510. set freezeControls(value: boolean);
  73511. /** Gets the bucket width */
  73512. get bucketWidth(): number;
  73513. /** Gets the bucket height */
  73514. get bucketHeight(): number;
  73515. /**
  73516. * Sets the bucket sizes.
  73517. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73518. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73519. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73520. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73521. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73522. * used), that's why it is not enabled by default.
  73523. * @param width width of the bucket
  73524. * @param height height of the bucket
  73525. */
  73526. setBucketSizes(width: number, height: number): void;
  73527. private _forceHorizontalBar;
  73528. private _forceVerticalBar;
  73529. /**
  73530. * Forces the horizontal scroll bar to be displayed
  73531. */
  73532. get forceHorizontalBar(): boolean;
  73533. set forceHorizontalBar(value: boolean);
  73534. /**
  73535. * Forces the vertical scroll bar to be displayed
  73536. */
  73537. get forceVerticalBar(): boolean;
  73538. set forceVerticalBar(value: boolean);
  73539. /**
  73540. * Creates a new ScrollViewer
  73541. * @param name of ScrollViewer
  73542. */
  73543. constructor(name?: string, isImageBased?: boolean);
  73544. /** Reset the scroll viewer window to initial size */
  73545. resetWindow(): void;
  73546. protected _getTypeName(): string;
  73547. private _buildClientSizes;
  73548. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73549. protected _postMeasure(): void;
  73550. /**
  73551. * Gets or sets the mouse wheel precision
  73552. * from 0 to 1 with a default value of 0.05
  73553. * */
  73554. get wheelPrecision(): number;
  73555. set wheelPrecision(value: number);
  73556. /** Gets or sets the scroll bar container background color */
  73557. get scrollBackground(): string;
  73558. set scrollBackground(color: string);
  73559. /** Gets or sets the bar color */
  73560. get barColor(): string;
  73561. set barColor(color: string);
  73562. /** Gets or sets the bar image */
  73563. get thumbImage(): Image;
  73564. set thumbImage(value: Image);
  73565. /** Gets or sets the horizontal bar image */
  73566. get horizontalThumbImage(): Image;
  73567. set horizontalThumbImage(value: Image);
  73568. /** Gets or sets the vertical bar image */
  73569. get verticalThumbImage(): Image;
  73570. set verticalThumbImage(value: Image);
  73571. /** Gets or sets the size of the bar */
  73572. get barSize(): number;
  73573. set barSize(value: number);
  73574. /** Gets or sets the length of the thumb */
  73575. get thumbLength(): number;
  73576. set thumbLength(value: number);
  73577. /** Gets or sets the height of the thumb */
  73578. get thumbHeight(): number;
  73579. set thumbHeight(value: number);
  73580. /** Gets or sets the height of the bar image */
  73581. get barImageHeight(): number;
  73582. set barImageHeight(value: number);
  73583. /** Gets or sets the height of the horizontal bar image */
  73584. get horizontalBarImageHeight(): number;
  73585. set horizontalBarImageHeight(value: number);
  73586. /** Gets or sets the height of the vertical bar image */
  73587. get verticalBarImageHeight(): number;
  73588. set verticalBarImageHeight(value: number);
  73589. /** Gets or sets the bar background */
  73590. get barBackground(): string;
  73591. set barBackground(color: string);
  73592. /** Gets or sets the bar background image */
  73593. get barImage(): Image;
  73594. set barImage(value: Image);
  73595. /** Gets or sets the horizontal bar background image */
  73596. get horizontalBarImage(): Image;
  73597. set horizontalBarImage(value: Image);
  73598. /** Gets or sets the vertical bar background image */
  73599. get verticalBarImage(): Image;
  73600. set verticalBarImage(value: Image);
  73601. private _setWindowPosition;
  73602. /** @hidden */
  73603. private _updateScroller;
  73604. _link(host: AdvancedDynamicTexture): void;
  73605. /** @hidden */
  73606. private _addBar;
  73607. /** @hidden */
  73608. private _attachWheel;
  73609. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73610. /** Releases associated resources */
  73611. dispose(): void;
  73612. }
  73613. }
  73614. declare module BABYLON.GUI {
  73615. /** Class used to render a grid */
  73616. export class DisplayGrid extends Control {
  73617. name?: string | undefined;
  73618. private _cellWidth;
  73619. private _cellHeight;
  73620. private _minorLineTickness;
  73621. private _minorLineColor;
  73622. private _majorLineTickness;
  73623. private _majorLineColor;
  73624. private _majorLineFrequency;
  73625. private _background;
  73626. private _displayMajorLines;
  73627. private _displayMinorLines;
  73628. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73629. get displayMinorLines(): boolean;
  73630. set displayMinorLines(value: boolean);
  73631. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73632. get displayMajorLines(): boolean;
  73633. set displayMajorLines(value: boolean);
  73634. /** Gets or sets background color (Black by default) */
  73635. get background(): string;
  73636. set background(value: string);
  73637. /** Gets or sets the width of each cell (20 by default) */
  73638. get cellWidth(): number;
  73639. set cellWidth(value: number);
  73640. /** Gets or sets the height of each cell (20 by default) */
  73641. get cellHeight(): number;
  73642. set cellHeight(value: number);
  73643. /** Gets or sets the tickness of minor lines (1 by default) */
  73644. get minorLineTickness(): number;
  73645. set minorLineTickness(value: number);
  73646. /** Gets or sets the color of minor lines (DarkGray by default) */
  73647. get minorLineColor(): string;
  73648. set minorLineColor(value: string);
  73649. /** Gets or sets the tickness of major lines (2 by default) */
  73650. get majorLineTickness(): number;
  73651. set majorLineTickness(value: number);
  73652. /** Gets or sets the color of major lines (White by default) */
  73653. get majorLineColor(): string;
  73654. set majorLineColor(value: string);
  73655. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73656. get majorLineFrequency(): number;
  73657. set majorLineFrequency(value: number);
  73658. /**
  73659. * Creates a new GridDisplayRectangle
  73660. * @param name defines the control name
  73661. */
  73662. constructor(name?: string | undefined);
  73663. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73664. protected _getTypeName(): string;
  73665. }
  73666. }
  73667. declare module BABYLON.GUI {
  73668. /**
  73669. * Class used to create slider controls based on images
  73670. */
  73671. export class ImageBasedSlider extends BaseSlider {
  73672. name?: string | undefined;
  73673. private _backgroundImage;
  73674. private _thumbImage;
  73675. private _valueBarImage;
  73676. private _tempMeasure;
  73677. get displayThumb(): boolean;
  73678. set displayThumb(value: boolean);
  73679. /**
  73680. * Gets or sets the image used to render the background
  73681. */
  73682. get backgroundImage(): Image;
  73683. set backgroundImage(value: Image);
  73684. /**
  73685. * Gets or sets the image used to render the value bar
  73686. */
  73687. get valueBarImage(): Image;
  73688. set valueBarImage(value: Image);
  73689. /**
  73690. * Gets or sets the image used to render the thumb
  73691. */
  73692. get thumbImage(): Image;
  73693. set thumbImage(value: Image);
  73694. /**
  73695. * Creates a new ImageBasedSlider
  73696. * @param name defines the control name
  73697. */
  73698. constructor(name?: string | undefined);
  73699. protected _getTypeName(): string;
  73700. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73701. }
  73702. }
  73703. declare module BABYLON.GUI {
  73704. /**
  73705. * Forcing an export so that this code will execute
  73706. * @hidden
  73707. */
  73708. const name = "Statics";
  73709. }
  73710. declare module BABYLON.GUI {
  73711. /**
  73712. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73713. */
  73714. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73715. /**
  73716. * Define the instrumented AdvancedDynamicTexture.
  73717. */
  73718. texture: AdvancedDynamicTexture;
  73719. private _captureRenderTime;
  73720. private _renderTime;
  73721. private _captureLayoutTime;
  73722. private _layoutTime;
  73723. private _onBeginRenderObserver;
  73724. private _onEndRenderObserver;
  73725. private _onBeginLayoutObserver;
  73726. private _onEndLayoutObserver;
  73727. /**
  73728. * Gets the perf counter used to capture render time
  73729. */
  73730. get renderTimeCounter(): BABYLON.PerfCounter;
  73731. /**
  73732. * Gets the perf counter used to capture layout time
  73733. */
  73734. get layoutTimeCounter(): BABYLON.PerfCounter;
  73735. /**
  73736. * Enable or disable the render time capture
  73737. */
  73738. get captureRenderTime(): boolean;
  73739. set captureRenderTime(value: boolean);
  73740. /**
  73741. * Enable or disable the layout time capture
  73742. */
  73743. get captureLayoutTime(): boolean;
  73744. set captureLayoutTime(value: boolean);
  73745. /**
  73746. * Instantiates a new advanced dynamic texture instrumentation.
  73747. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73748. * @param texture Defines the AdvancedDynamicTexture to instrument
  73749. */
  73750. constructor(
  73751. /**
  73752. * Define the instrumented AdvancedDynamicTexture.
  73753. */
  73754. texture: AdvancedDynamicTexture);
  73755. /**
  73756. * Dispose and release associated resources.
  73757. */
  73758. dispose(): void;
  73759. }
  73760. }
  73761. declare module BABYLON.GUI {
  73762. /**
  73763. * Class used to load GUI via XML.
  73764. */
  73765. export class XmlLoader {
  73766. private _nodes;
  73767. private _nodeTypes;
  73768. private _isLoaded;
  73769. private _objectAttributes;
  73770. private _parentClass;
  73771. /**
  73772. * Create a new xml loader
  73773. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73774. */
  73775. constructor(parentClass?: null);
  73776. private _getChainElement;
  73777. private _getClassAttribute;
  73778. private _createGuiElement;
  73779. private _parseGrid;
  73780. private _parseElement;
  73781. private _prepareSourceElement;
  73782. private _parseElementsFromSource;
  73783. private _parseXml;
  73784. /**
  73785. * Gets if the loading has finished.
  73786. * @returns whether the loading has finished or not
  73787. */
  73788. isLoaded(): boolean;
  73789. /**
  73790. * Gets a loaded node / control by id.
  73791. * @param id the Controls id set in the xml
  73792. * @returns element of type Control
  73793. */
  73794. getNodeById(id: string): any;
  73795. /**
  73796. * Gets all loaded nodes / controls
  73797. * @returns Array of controls
  73798. */
  73799. getNodes(): any;
  73800. /**
  73801. * Initiates the xml layout loading
  73802. * @param xmlFile defines the xml layout to load
  73803. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73804. * @param callback defines the callback called on layout load.
  73805. */
  73806. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73807. }
  73808. }
  73809. declare module BABYLON.GUI {
  73810. /**
  73811. * Class used to create containers for controls
  73812. */
  73813. export class Container3D extends Control3D {
  73814. private _blockLayout;
  73815. /**
  73816. * Gets the list of child controls
  73817. */
  73818. protected _children: Control3D[];
  73819. /**
  73820. * Gets the list of child controls
  73821. */
  73822. get children(): Array<Control3D>;
  73823. /**
  73824. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73825. * This is helpful to optimize layout operation when adding multiple children in a row
  73826. */
  73827. get blockLayout(): boolean;
  73828. set blockLayout(value: boolean);
  73829. /**
  73830. * Creates a new container
  73831. * @param name defines the container name
  73832. */
  73833. constructor(name?: string);
  73834. /**
  73835. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73836. * @returns the current container
  73837. */
  73838. updateLayout(): Container3D;
  73839. /**
  73840. * Gets a boolean indicating if the given control is in the children of this control
  73841. * @param control defines the control to check
  73842. * @returns true if the control is in the child list
  73843. */
  73844. containsControl(control: Control3D): boolean;
  73845. /**
  73846. * Adds a control to the children of this control
  73847. * @param control defines the control to add
  73848. * @returns the current container
  73849. */
  73850. addControl(control: Control3D): Container3D;
  73851. /**
  73852. * This function will be called everytime a new control is added
  73853. */
  73854. protected _arrangeChildren(): void;
  73855. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73856. /**
  73857. * Removes a control from the children of this control
  73858. * @param control defines the control to remove
  73859. * @returns the current container
  73860. */
  73861. removeControl(control: Control3D): Container3D;
  73862. protected _getTypeName(): string;
  73863. /**
  73864. * Releases all associated resources
  73865. */
  73866. dispose(): void;
  73867. /** Control rotation will remain unchanged */
  73868. static readonly UNSET_ORIENTATION: number;
  73869. /** Control will rotate to make it look at sphere central axis */
  73870. static readonly FACEORIGIN_ORIENTATION: number;
  73871. /** Control will rotate to make it look back at sphere central axis */
  73872. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73873. /** Control will rotate to look at z axis (0, 0, 1) */
  73874. static readonly FACEFORWARD_ORIENTATION: number;
  73875. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73876. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73877. }
  73878. }
  73879. declare module BABYLON.GUI {
  73880. /**
  73881. * Class used to manage 3D user interface
  73882. * @see http://doc.babylonjs.com/how_to/gui3d
  73883. */
  73884. export class GUI3DManager implements BABYLON.IDisposable {
  73885. private _scene;
  73886. private _sceneDisposeObserver;
  73887. private _utilityLayer;
  73888. private _rootContainer;
  73889. private _pointerObserver;
  73890. private _pointerOutObserver;
  73891. /** @hidden */
  73892. _lastPickedControl: Control3D;
  73893. /** @hidden */
  73894. _lastControlOver: {
  73895. [pointerId: number]: Control3D;
  73896. };
  73897. /** @hidden */
  73898. _lastControlDown: {
  73899. [pointerId: number]: Control3D;
  73900. };
  73901. /**
  73902. * BABYLON.Observable raised when the point picked by the pointer events changed
  73903. */
  73904. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73905. /** @hidden */
  73906. _sharedMaterials: {
  73907. [key: string]: BABYLON.Material;
  73908. };
  73909. /** Gets the hosting scene */
  73910. get scene(): BABYLON.Scene;
  73911. /** Gets associated utility layer */
  73912. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73913. /**
  73914. * Creates a new GUI3DManager
  73915. * @param scene
  73916. */
  73917. constructor(scene?: BABYLON.Scene);
  73918. private _handlePointerOut;
  73919. private _doPicking;
  73920. /**
  73921. * Gets the root container
  73922. */
  73923. get rootContainer(): Container3D;
  73924. /**
  73925. * Gets a boolean indicating if the given control is in the root child list
  73926. * @param control defines the control to check
  73927. * @returns true if the control is in the root child list
  73928. */
  73929. containsControl(control: Control3D): boolean;
  73930. /**
  73931. * Adds a control to the root child list
  73932. * @param control defines the control to add
  73933. * @returns the current manager
  73934. */
  73935. addControl(control: Control3D): GUI3DManager;
  73936. /**
  73937. * Removes a control from the root child list
  73938. * @param control defines the control to remove
  73939. * @returns the current container
  73940. */
  73941. removeControl(control: Control3D): GUI3DManager;
  73942. /**
  73943. * Releases all associated resources
  73944. */
  73945. dispose(): void;
  73946. }
  73947. }
  73948. declare module BABYLON.GUI {
  73949. /**
  73950. * Class used to transport BABYLON.Vector3 information for pointer events
  73951. */
  73952. export class Vector3WithInfo extends BABYLON.Vector3 {
  73953. /** defines the current mouse button index */
  73954. buttonIndex: number;
  73955. /**
  73956. * Creates a new Vector3WithInfo
  73957. * @param source defines the vector3 data to transport
  73958. * @param buttonIndex defines the current mouse button index
  73959. */
  73960. constructor(source: BABYLON.Vector3,
  73961. /** defines the current mouse button index */
  73962. buttonIndex?: number);
  73963. }
  73964. }
  73965. declare module BABYLON.GUI {
  73966. /**
  73967. * Class used as base class for controls
  73968. */
  73969. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73970. /** Defines the control name */
  73971. name?: string | undefined;
  73972. /** @hidden */
  73973. _host: GUI3DManager;
  73974. private _node;
  73975. private _downCount;
  73976. private _enterCount;
  73977. private _downPointerIds;
  73978. private _isVisible;
  73979. /** Gets or sets the control position in world space */
  73980. get position(): BABYLON.Vector3;
  73981. set position(value: BABYLON.Vector3);
  73982. /** Gets or sets the control scaling in world space */
  73983. get scaling(): BABYLON.Vector3;
  73984. set scaling(value: BABYLON.Vector3);
  73985. /** Callback used to start pointer enter animation */
  73986. pointerEnterAnimation: () => void;
  73987. /** Callback used to start pointer out animation */
  73988. pointerOutAnimation: () => void;
  73989. /** Callback used to start pointer down animation */
  73990. pointerDownAnimation: () => void;
  73991. /** Callback used to start pointer up animation */
  73992. pointerUpAnimation: () => void;
  73993. /**
  73994. * An event triggered when the pointer move over the control
  73995. */
  73996. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73997. /**
  73998. * An event triggered when the pointer move out of the control
  73999. */
  74000. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74001. /**
  74002. * An event triggered when the pointer taps the control
  74003. */
  74004. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74005. /**
  74006. * An event triggered when pointer is up
  74007. */
  74008. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74009. /**
  74010. * An event triggered when a control is clicked on (with a mouse)
  74011. */
  74012. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74013. /**
  74014. * An event triggered when pointer enters the control
  74015. */
  74016. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74017. /**
  74018. * Gets or sets the parent container
  74019. */
  74020. parent: BABYLON.Nullable<Container3D>;
  74021. private _behaviors;
  74022. /**
  74023. * Gets the list of attached behaviors
  74024. * @see http://doc.babylonjs.com/features/behaviour
  74025. */
  74026. get behaviors(): BABYLON.Behavior<Control3D>[];
  74027. /**
  74028. * Attach a behavior to the control
  74029. * @see http://doc.babylonjs.com/features/behaviour
  74030. * @param behavior defines the behavior to attach
  74031. * @returns the current control
  74032. */
  74033. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74034. /**
  74035. * Remove an attached behavior
  74036. * @see http://doc.babylonjs.com/features/behaviour
  74037. * @param behavior defines the behavior to attach
  74038. * @returns the current control
  74039. */
  74040. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74041. /**
  74042. * Gets an attached behavior by name
  74043. * @param name defines the name of the behavior to look for
  74044. * @see http://doc.babylonjs.com/features/behaviour
  74045. * @returns null if behavior was not found else the requested behavior
  74046. */
  74047. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74048. /** Gets or sets a boolean indicating if the control is visible */
  74049. get isVisible(): boolean;
  74050. set isVisible(value: boolean);
  74051. /**
  74052. * Creates a new control
  74053. * @param name defines the control name
  74054. */
  74055. constructor(
  74056. /** Defines the control name */
  74057. name?: string | undefined);
  74058. /**
  74059. * Gets a string representing the class name
  74060. */
  74061. get typeName(): string;
  74062. /**
  74063. * Get the current class name of the control.
  74064. * @returns current class name
  74065. */
  74066. getClassName(): string;
  74067. protected _getTypeName(): string;
  74068. /**
  74069. * Gets the transform node used by this control
  74070. */
  74071. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74072. /**
  74073. * Gets the mesh used to render this control
  74074. */
  74075. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74076. /**
  74077. * Link the control as child of the given node
  74078. * @param node defines the node to link to. Use null to unlink the control
  74079. * @returns the current control
  74080. */
  74081. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74082. /** @hidden **/
  74083. _prepareNode(scene: BABYLON.Scene): void;
  74084. /**
  74085. * Node creation.
  74086. * Can be overriden by children
  74087. * @param scene defines the scene where the node must be attached
  74088. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74089. */
  74090. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74091. /**
  74092. * Affect a material to the given mesh
  74093. * @param mesh defines the mesh which will represent the control
  74094. */
  74095. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74096. /** @hidden */
  74097. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74098. /** @hidden */
  74099. _onPointerEnter(target: Control3D): boolean;
  74100. /** @hidden */
  74101. _onPointerOut(target: Control3D): void;
  74102. /** @hidden */
  74103. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74104. /** @hidden */
  74105. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74106. /** @hidden */
  74107. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74108. /** @hidden */
  74109. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74110. /** @hidden */
  74111. _disposeNode(): void;
  74112. /**
  74113. * Releases all associated resources
  74114. */
  74115. dispose(): void;
  74116. }
  74117. }
  74118. declare module BABYLON.GUI {
  74119. /**
  74120. * Class used as a root to all buttons
  74121. */
  74122. export class AbstractButton3D extends Control3D {
  74123. /**
  74124. * Creates a new button
  74125. * @param name defines the control name
  74126. */
  74127. constructor(name?: string);
  74128. protected _getTypeName(): string;
  74129. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74130. }
  74131. }
  74132. declare module BABYLON.GUI {
  74133. /**
  74134. * Class used to create a button in 3D
  74135. */
  74136. export class Button3D extends AbstractButton3D {
  74137. /** @hidden */
  74138. protected _currentMaterial: BABYLON.Material;
  74139. private _facadeTexture;
  74140. private _content;
  74141. private _contentResolution;
  74142. private _contentScaleRatio;
  74143. /**
  74144. * Gets or sets the texture resolution used to render content (512 by default)
  74145. */
  74146. get contentResolution(): BABYLON.int;
  74147. set contentResolution(value: BABYLON.int);
  74148. /**
  74149. * Gets or sets the texture scale ratio used to render content (2 by default)
  74150. */
  74151. get contentScaleRatio(): number;
  74152. set contentScaleRatio(value: number);
  74153. protected _disposeFacadeTexture(): void;
  74154. protected _resetContent(): void;
  74155. /**
  74156. * Creates a new button
  74157. * @param name defines the control name
  74158. */
  74159. constructor(name?: string);
  74160. /**
  74161. * Gets or sets the GUI 2D content used to display the button's facade
  74162. */
  74163. get content(): Control;
  74164. set content(value: Control);
  74165. /**
  74166. * Apply the facade texture (created from the content property).
  74167. * This function can be overloaded by child classes
  74168. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74169. */
  74170. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74171. protected _getTypeName(): string;
  74172. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74173. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74174. /**
  74175. * Releases all associated resources
  74176. */
  74177. dispose(): void;
  74178. }
  74179. }
  74180. declare module BABYLON.GUI {
  74181. /**
  74182. * Abstract class used to create a container panel deployed on the surface of a volume
  74183. */
  74184. export abstract class VolumeBasedPanel extends Container3D {
  74185. private _columns;
  74186. private _rows;
  74187. private _rowThenColum;
  74188. private _orientation;
  74189. protected _cellWidth: number;
  74190. protected _cellHeight: number;
  74191. /**
  74192. * Gets or sets the distance between elements
  74193. */
  74194. margin: number;
  74195. /**
  74196. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74197. * | Value | Type | Description |
  74198. * | ----- | ----------------------------------- | ----------- |
  74199. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74200. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74201. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74202. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74203. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74204. */
  74205. get orientation(): number;
  74206. set orientation(value: number);
  74207. /**
  74208. * Gets or sets the number of columns requested (10 by default).
  74209. * The panel will automatically compute the number of rows based on number of child controls.
  74210. */
  74211. get columns(): BABYLON.int;
  74212. set columns(value: BABYLON.int);
  74213. /**
  74214. * Gets or sets a the number of rows requested.
  74215. * The panel will automatically compute the number of columns based on number of child controls.
  74216. */
  74217. get rows(): BABYLON.int;
  74218. set rows(value: BABYLON.int);
  74219. /**
  74220. * Creates new VolumeBasedPanel
  74221. */
  74222. constructor();
  74223. protected _arrangeChildren(): void;
  74224. /** Child classes must implement this function to provide correct control positioning */
  74225. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74226. /** Child classes can implement this function to provide additional processing */
  74227. protected _finalProcessing(): void;
  74228. }
  74229. }
  74230. declare module BABYLON.GUI {
  74231. /**
  74232. * Class used to create a container panel deployed on the surface of a cylinder
  74233. */
  74234. export class CylinderPanel extends VolumeBasedPanel {
  74235. private _radius;
  74236. /**
  74237. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74238. */
  74239. get radius(): BABYLON.float;
  74240. set radius(value: BABYLON.float);
  74241. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74242. private _cylindricalMapping;
  74243. }
  74244. }
  74245. declare module BABYLON.GUI {
  74246. /** @hidden */
  74247. export var fluentVertexShader: {
  74248. name: string;
  74249. shader: string;
  74250. };
  74251. }
  74252. declare module BABYLON.GUI {
  74253. /** @hidden */
  74254. export var fluentPixelShader: {
  74255. name: string;
  74256. shader: string;
  74257. };
  74258. }
  74259. declare module BABYLON.GUI {
  74260. /** @hidden */
  74261. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74262. INNERGLOW: boolean;
  74263. BORDER: boolean;
  74264. HOVERLIGHT: boolean;
  74265. TEXTURE: boolean;
  74266. constructor();
  74267. }
  74268. /**
  74269. * Class used to render controls with fluent desgin
  74270. */
  74271. export class FluentMaterial extends BABYLON.PushMaterial {
  74272. /**
  74273. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74274. */
  74275. innerGlowColorIntensity: number;
  74276. /**
  74277. * Gets or sets the inner glow color (white by default)
  74278. */
  74279. innerGlowColor: BABYLON.Color3;
  74280. /**
  74281. * Gets or sets alpha value (default is 1.0)
  74282. */
  74283. alpha: number;
  74284. /**
  74285. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74286. */
  74287. albedoColor: BABYLON.Color3;
  74288. /**
  74289. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74290. */
  74291. renderBorders: boolean;
  74292. /**
  74293. * Gets or sets border width (default is 0.5)
  74294. */
  74295. borderWidth: number;
  74296. /**
  74297. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74298. */
  74299. edgeSmoothingValue: number;
  74300. /**
  74301. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74302. */
  74303. borderMinValue: number;
  74304. /**
  74305. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74306. */
  74307. renderHoverLight: boolean;
  74308. /**
  74309. * Gets or sets the radius used to render the hover light (default is 1.0)
  74310. */
  74311. hoverRadius: number;
  74312. /**
  74313. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74314. */
  74315. hoverColor: BABYLON.Color4;
  74316. /**
  74317. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74318. */
  74319. hoverPosition: BABYLON.Vector3;
  74320. private _albedoTexture;
  74321. /** Gets or sets the texture to use for albedo color */
  74322. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74323. /**
  74324. * Creates a new Fluent material
  74325. * @param name defines the name of the material
  74326. * @param scene defines the hosting scene
  74327. */
  74328. constructor(name: string, scene: BABYLON.Scene);
  74329. needAlphaBlending(): boolean;
  74330. needAlphaTesting(): boolean;
  74331. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74334. getActiveTextures(): BABYLON.BaseTexture[];
  74335. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74336. dispose(forceDisposeEffect?: boolean): void;
  74337. clone(name: string): FluentMaterial;
  74338. serialize(): any;
  74339. getClassName(): string;
  74340. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74341. }
  74342. }
  74343. declare module BABYLON.GUI {
  74344. /**
  74345. * Class used to create a holographic button in 3D
  74346. */
  74347. export class HolographicButton extends Button3D {
  74348. private _backPlate;
  74349. private _textPlate;
  74350. private _frontPlate;
  74351. private _text;
  74352. private _imageUrl;
  74353. private _shareMaterials;
  74354. private _frontMaterial;
  74355. private _backMaterial;
  74356. private _plateMaterial;
  74357. private _pickedPointObserver;
  74358. private _tooltipFade;
  74359. private _tooltipTextBlock;
  74360. private _tooltipTexture;
  74361. private _tooltipMesh;
  74362. private _tooltipHoverObserver;
  74363. private _tooltipOutObserver;
  74364. private _disposeTooltip;
  74365. /**
  74366. * Rendering ground id of all the mesh in the button
  74367. */
  74368. set renderingGroupId(id: number);
  74369. get renderingGroupId(): number;
  74370. /**
  74371. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74372. */
  74373. set tooltipText(text: BABYLON.Nullable<string>);
  74374. get tooltipText(): BABYLON.Nullable<string>;
  74375. /**
  74376. * Gets or sets text for the button
  74377. */
  74378. get text(): string;
  74379. set text(value: string);
  74380. /**
  74381. * Gets or sets the image url for the button
  74382. */
  74383. get imageUrl(): string;
  74384. set imageUrl(value: string);
  74385. /**
  74386. * Gets the back material used by this button
  74387. */
  74388. get backMaterial(): FluentMaterial;
  74389. /**
  74390. * Gets the front material used by this button
  74391. */
  74392. get frontMaterial(): FluentMaterial;
  74393. /**
  74394. * Gets the plate material used by this button
  74395. */
  74396. get plateMaterial(): BABYLON.StandardMaterial;
  74397. /**
  74398. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74399. */
  74400. get shareMaterials(): boolean;
  74401. /**
  74402. * Creates a new button
  74403. * @param name defines the control name
  74404. */
  74405. constructor(name?: string, shareMaterials?: boolean);
  74406. protected _getTypeName(): string;
  74407. private _rebuildContent;
  74408. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74409. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74410. private _createBackMaterial;
  74411. private _createFrontMaterial;
  74412. private _createPlateMaterial;
  74413. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74414. /**
  74415. * Releases all associated resources
  74416. */
  74417. dispose(): void;
  74418. }
  74419. }
  74420. declare module BABYLON.GUI {
  74421. /**
  74422. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74423. */
  74424. export class MeshButton3D extends Button3D {
  74425. /** @hidden */
  74426. protected _currentMesh: BABYLON.Mesh;
  74427. /**
  74428. * Creates a new 3D button based on a mesh
  74429. * @param mesh mesh to become a 3D button
  74430. * @param name defines the control name
  74431. */
  74432. constructor(mesh: BABYLON.Mesh, name?: string);
  74433. protected _getTypeName(): string;
  74434. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74435. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74436. }
  74437. }
  74438. declare module BABYLON.GUI {
  74439. /**
  74440. * Class used to create a container panel deployed on the surface of a plane
  74441. */
  74442. export class PlanePanel extends VolumeBasedPanel {
  74443. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74444. }
  74445. }
  74446. declare module BABYLON.GUI {
  74447. /**
  74448. * Class used to create a container panel where items get randomized planar mapping
  74449. */
  74450. export class ScatterPanel extends VolumeBasedPanel {
  74451. private _iteration;
  74452. /**
  74453. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74454. */
  74455. get iteration(): BABYLON.float;
  74456. set iteration(value: BABYLON.float);
  74457. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74458. private _scatterMapping;
  74459. protected _finalProcessing(): void;
  74460. }
  74461. }
  74462. declare module BABYLON.GUI {
  74463. /**
  74464. * Class used to create a container panel deployed on the surface of a sphere
  74465. */
  74466. export class SpherePanel extends VolumeBasedPanel {
  74467. private _radius;
  74468. /**
  74469. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74470. */
  74471. get radius(): BABYLON.float;
  74472. set radius(value: BABYLON.float);
  74473. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74474. private _sphericalMapping;
  74475. }
  74476. }
  74477. declare module BABYLON.GUI {
  74478. /**
  74479. * Class used to create a stack panel in 3D on XY plane
  74480. */
  74481. export class StackPanel3D extends Container3D {
  74482. private _isVertical;
  74483. /**
  74484. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74485. */
  74486. get isVertical(): boolean;
  74487. set isVertical(value: boolean);
  74488. /**
  74489. * Gets or sets the distance between elements
  74490. */
  74491. margin: number;
  74492. /**
  74493. * Creates new StackPanel
  74494. * @param isVertical
  74495. */
  74496. constructor(isVertical?: boolean);
  74497. protected _arrangeChildren(): void;
  74498. }
  74499. }
  74500. declare module BABYLON {
  74501. /**
  74502. * Configuration for glTF validation
  74503. */
  74504. export interface IGLTFValidationConfiguration {
  74505. /**
  74506. * The url of the glTF validator.
  74507. */
  74508. url: string;
  74509. }
  74510. /**
  74511. * glTF validation
  74512. */
  74513. export class GLTFValidation {
  74514. /**
  74515. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74516. */
  74517. static Configuration: IGLTFValidationConfiguration;
  74518. private static _LoadScriptPromise;
  74519. /**
  74520. * Validate a glTF asset using the glTF-Validator.
  74521. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74522. * @param rootUrl The root url for the glTF
  74523. * @param fileName The file name for the glTF
  74524. * @param getExternalResource The callback to get external resources for the glTF validator
  74525. * @returns A promise that resolves with the glTF validation results once complete
  74526. */
  74527. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74528. }
  74529. }
  74530. declare module BABYLON {
  74531. /**
  74532. * Mode that determines the coordinate system to use.
  74533. */
  74534. export enum GLTFLoaderCoordinateSystemMode {
  74535. /**
  74536. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74537. */
  74538. AUTO = 0,
  74539. /**
  74540. * Sets the useRightHandedSystem flag on the scene.
  74541. */
  74542. FORCE_RIGHT_HANDED = 1
  74543. }
  74544. /**
  74545. * Mode that determines what animations will start.
  74546. */
  74547. export enum GLTFLoaderAnimationStartMode {
  74548. /**
  74549. * No animation will start.
  74550. */
  74551. NONE = 0,
  74552. /**
  74553. * The first animation will start.
  74554. */
  74555. FIRST = 1,
  74556. /**
  74557. * All animations will start.
  74558. */
  74559. ALL = 2
  74560. }
  74561. /**
  74562. * Interface that contains the data for the glTF asset.
  74563. */
  74564. export interface IGLTFLoaderData {
  74565. /**
  74566. * The object that represents the glTF JSON.
  74567. */
  74568. json: Object;
  74569. /**
  74570. * The BIN chunk of a binary glTF.
  74571. */
  74572. bin: Nullable<IDataBuffer>;
  74573. }
  74574. /**
  74575. * Interface for extending the loader.
  74576. */
  74577. export interface IGLTFLoaderExtension {
  74578. /**
  74579. * The name of this extension.
  74580. */
  74581. readonly name: string;
  74582. /**
  74583. * Defines whether this extension is enabled.
  74584. */
  74585. enabled: boolean;
  74586. /**
  74587. * Defines the order of this extension.
  74588. * The loader sorts the extensions using these values when loading.
  74589. */
  74590. order?: number;
  74591. }
  74592. /**
  74593. * Loader state.
  74594. */
  74595. export enum GLTFLoaderState {
  74596. /**
  74597. * The asset is loading.
  74598. */
  74599. LOADING = 0,
  74600. /**
  74601. * The asset is ready for rendering.
  74602. */
  74603. READY = 1,
  74604. /**
  74605. * The asset is completely loaded.
  74606. */
  74607. COMPLETE = 2
  74608. }
  74609. /** @hidden */
  74610. export interface IImportMeshAsyncOutput {
  74611. meshes: AbstractMesh[];
  74612. particleSystems: IParticleSystem[];
  74613. skeletons: Skeleton[];
  74614. animationGroups: AnimationGroup[];
  74615. lights: Light[];
  74616. transformNodes: TransformNode[];
  74617. }
  74618. /** @hidden */
  74619. export interface IGLTFLoader extends IDisposable {
  74620. readonly state: Nullable<GLTFLoaderState>;
  74621. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74622. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74623. }
  74624. /**
  74625. * File loader for loading glTF files into a scene.
  74626. */
  74627. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74628. /** @hidden */
  74629. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74630. /** @hidden */
  74631. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74632. /**
  74633. * Raised when the asset has been parsed
  74634. */
  74635. onParsedObservable: Observable<IGLTFLoaderData>;
  74636. private _onParsedObserver;
  74637. /**
  74638. * Raised when the asset has been parsed
  74639. */
  74640. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74641. /**
  74642. * 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.
  74643. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74644. * Defaults to true.
  74645. * @hidden
  74646. */
  74647. static IncrementalLoading: boolean;
  74648. /**
  74649. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74650. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74651. * @hidden
  74652. */
  74653. static HomogeneousCoordinates: boolean;
  74654. /**
  74655. * The coordinate system mode. Defaults to AUTO.
  74656. */
  74657. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74658. /**
  74659. * The animation start mode. Defaults to FIRST.
  74660. */
  74661. animationStartMode: GLTFLoaderAnimationStartMode;
  74662. /**
  74663. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74664. */
  74665. compileMaterials: boolean;
  74666. /**
  74667. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74668. */
  74669. useClipPlane: boolean;
  74670. /**
  74671. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74672. */
  74673. compileShadowGenerators: boolean;
  74674. /**
  74675. * Defines if the Alpha blended materials are only applied as coverage.
  74676. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74677. * If true, no extra effects are applied to transparent pixels.
  74678. */
  74679. transparencyAsCoverage: boolean;
  74680. /**
  74681. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74682. * Enabling will disable offline support and glTF validator.
  74683. * Defaults to false.
  74684. */
  74685. useRangeRequests: boolean;
  74686. /**
  74687. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74688. */
  74689. createInstances: boolean;
  74690. /**
  74691. * Function called before loading a url referenced by the asset.
  74692. */
  74693. preprocessUrlAsync: (url: string) => Promise<string>;
  74694. /**
  74695. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74696. */
  74697. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74698. private _onMeshLoadedObserver;
  74699. /**
  74700. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74701. */
  74702. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74703. /**
  74704. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74705. */
  74706. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74707. private _onTextureLoadedObserver;
  74708. /**
  74709. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74710. */
  74711. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74712. /**
  74713. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74714. */
  74715. readonly onMaterialLoadedObservable: Observable<Material>;
  74716. private _onMaterialLoadedObserver;
  74717. /**
  74718. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74719. */
  74720. set onMaterialLoaded(callback: (material: Material) => void);
  74721. /**
  74722. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74723. */
  74724. readonly onCameraLoadedObservable: Observable<Camera>;
  74725. private _onCameraLoadedObserver;
  74726. /**
  74727. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74728. */
  74729. set onCameraLoaded(callback: (camera: Camera) => void);
  74730. /**
  74731. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74732. * For assets with LODs, raised when all of the LODs are complete.
  74733. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74734. */
  74735. readonly onCompleteObservable: Observable<void>;
  74736. private _onCompleteObserver;
  74737. /**
  74738. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74739. * For assets with LODs, raised when all of the LODs are complete.
  74740. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74741. */
  74742. set onComplete(callback: () => void);
  74743. /**
  74744. * Observable raised when an error occurs.
  74745. */
  74746. readonly onErrorObservable: Observable<any>;
  74747. private _onErrorObserver;
  74748. /**
  74749. * Callback raised when an error occurs.
  74750. */
  74751. set onError(callback: (reason: any) => void);
  74752. /**
  74753. * Observable raised after the loader is disposed.
  74754. */
  74755. readonly onDisposeObservable: Observable<void>;
  74756. private _onDisposeObserver;
  74757. /**
  74758. * Callback raised after the loader is disposed.
  74759. */
  74760. set onDispose(callback: () => void);
  74761. /**
  74762. * Observable raised after a loader extension is created.
  74763. * Set additional options for a loader extension in this event.
  74764. */
  74765. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74766. private _onExtensionLoadedObserver;
  74767. /**
  74768. * Callback raised after a loader extension is created.
  74769. */
  74770. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74771. /**
  74772. * Defines if the loader logging is enabled.
  74773. */
  74774. get loggingEnabled(): boolean;
  74775. set loggingEnabled(value: boolean);
  74776. /**
  74777. * Defines if the loader should capture performance counters.
  74778. */
  74779. get capturePerformanceCounters(): boolean;
  74780. set capturePerformanceCounters(value: boolean);
  74781. /**
  74782. * Defines if the loader should validate the asset.
  74783. */
  74784. validate: boolean;
  74785. /**
  74786. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74787. */
  74788. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74789. private _onValidatedObserver;
  74790. /**
  74791. * Callback raised after a loader extension is created.
  74792. */
  74793. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74794. private _loader;
  74795. /**
  74796. * Name of the loader ("gltf")
  74797. */
  74798. name: string;
  74799. /** @hidden */
  74800. extensions: ISceneLoaderPluginExtensions;
  74801. /**
  74802. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74803. */
  74804. dispose(): void;
  74805. /** @hidden */
  74806. _clear(): void;
  74807. /** @hidden */
  74808. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74809. /** @hidden */
  74810. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74811. /** @hidden */
  74812. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74813. meshes: AbstractMesh[];
  74814. particleSystems: IParticleSystem[];
  74815. skeletons: Skeleton[];
  74816. animationGroups: AnimationGroup[];
  74817. }>;
  74818. /** @hidden */
  74819. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74820. /** @hidden */
  74821. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74822. /** @hidden */
  74823. canDirectLoad(data: string): boolean;
  74824. /** @hidden */
  74825. directLoad(scene: Scene, data: string): any;
  74826. /**
  74827. * The callback that allows custom handling of the root url based on the response url.
  74828. * @param rootUrl the original root url
  74829. * @param responseURL the response url if available
  74830. * @returns the new root url
  74831. */
  74832. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74833. /** @hidden */
  74834. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74835. /**
  74836. * The loader state or null if the loader is not active.
  74837. */
  74838. get loaderState(): Nullable<GLTFLoaderState>;
  74839. /**
  74840. * Returns a promise that resolves when the asset is completely loaded.
  74841. * @returns a promise that resolves when the asset is completely loaded.
  74842. */
  74843. whenCompleteAsync(): Promise<void>;
  74844. private _validate;
  74845. private _getLoader;
  74846. private _parseJson;
  74847. private _unpackBinaryAsync;
  74848. private _unpackBinaryV1Async;
  74849. private _unpackBinaryV2Async;
  74850. private static _parseVersion;
  74851. private static _compareVersion;
  74852. private static readonly _logSpaces;
  74853. private _logIndentLevel;
  74854. private _loggingEnabled;
  74855. /** @hidden */
  74856. _log: (message: string) => void;
  74857. /** @hidden */
  74858. _logOpen(message: string): void;
  74859. /** @hidden */
  74860. _logClose(): void;
  74861. private _logEnabled;
  74862. private _logDisabled;
  74863. private _capturePerformanceCounters;
  74864. /** @hidden */
  74865. _startPerformanceCounter: (counterName: string) => void;
  74866. /** @hidden */
  74867. _endPerformanceCounter: (counterName: string) => void;
  74868. private _startPerformanceCounterEnabled;
  74869. private _startPerformanceCounterDisabled;
  74870. private _endPerformanceCounterEnabled;
  74871. private _endPerformanceCounterDisabled;
  74872. }
  74873. }
  74874. declare module BABYLON.GLTF1 {
  74875. /**
  74876. * Enums
  74877. * @hidden
  74878. */
  74879. export enum EComponentType {
  74880. BYTE = 5120,
  74881. UNSIGNED_BYTE = 5121,
  74882. SHORT = 5122,
  74883. UNSIGNED_SHORT = 5123,
  74884. FLOAT = 5126
  74885. }
  74886. /** @hidden */
  74887. export enum EShaderType {
  74888. FRAGMENT = 35632,
  74889. VERTEX = 35633
  74890. }
  74891. /** @hidden */
  74892. export enum EParameterType {
  74893. BYTE = 5120,
  74894. UNSIGNED_BYTE = 5121,
  74895. SHORT = 5122,
  74896. UNSIGNED_SHORT = 5123,
  74897. INT = 5124,
  74898. UNSIGNED_INT = 5125,
  74899. FLOAT = 5126,
  74900. FLOAT_VEC2 = 35664,
  74901. FLOAT_VEC3 = 35665,
  74902. FLOAT_VEC4 = 35666,
  74903. INT_VEC2 = 35667,
  74904. INT_VEC3 = 35668,
  74905. INT_VEC4 = 35669,
  74906. BOOL = 35670,
  74907. BOOL_VEC2 = 35671,
  74908. BOOL_VEC3 = 35672,
  74909. BOOL_VEC4 = 35673,
  74910. FLOAT_MAT2 = 35674,
  74911. FLOAT_MAT3 = 35675,
  74912. FLOAT_MAT4 = 35676,
  74913. SAMPLER_2D = 35678
  74914. }
  74915. /** @hidden */
  74916. export enum ETextureWrapMode {
  74917. CLAMP_TO_EDGE = 33071,
  74918. MIRRORED_REPEAT = 33648,
  74919. REPEAT = 10497
  74920. }
  74921. /** @hidden */
  74922. export enum ETextureFilterType {
  74923. NEAREST = 9728,
  74924. LINEAR = 9728,
  74925. NEAREST_MIPMAP_NEAREST = 9984,
  74926. LINEAR_MIPMAP_NEAREST = 9985,
  74927. NEAREST_MIPMAP_LINEAR = 9986,
  74928. LINEAR_MIPMAP_LINEAR = 9987
  74929. }
  74930. /** @hidden */
  74931. export enum ETextureFormat {
  74932. ALPHA = 6406,
  74933. RGB = 6407,
  74934. RGBA = 6408,
  74935. LUMINANCE = 6409,
  74936. LUMINANCE_ALPHA = 6410
  74937. }
  74938. /** @hidden */
  74939. export enum ECullingType {
  74940. FRONT = 1028,
  74941. BACK = 1029,
  74942. FRONT_AND_BACK = 1032
  74943. }
  74944. /** @hidden */
  74945. export enum EBlendingFunction {
  74946. ZERO = 0,
  74947. ONE = 1,
  74948. SRC_COLOR = 768,
  74949. ONE_MINUS_SRC_COLOR = 769,
  74950. DST_COLOR = 774,
  74951. ONE_MINUS_DST_COLOR = 775,
  74952. SRC_ALPHA = 770,
  74953. ONE_MINUS_SRC_ALPHA = 771,
  74954. DST_ALPHA = 772,
  74955. ONE_MINUS_DST_ALPHA = 773,
  74956. CONSTANT_COLOR = 32769,
  74957. ONE_MINUS_CONSTANT_COLOR = 32770,
  74958. CONSTANT_ALPHA = 32771,
  74959. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74960. SRC_ALPHA_SATURATE = 776
  74961. }
  74962. /** @hidden */
  74963. export interface IGLTFProperty {
  74964. extensions?: {
  74965. [key: string]: any;
  74966. };
  74967. extras?: Object;
  74968. }
  74969. /** @hidden */
  74970. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74971. name?: string;
  74972. }
  74973. /** @hidden */
  74974. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74975. bufferView: string;
  74976. byteOffset: number;
  74977. byteStride: number;
  74978. count: number;
  74979. type: string;
  74980. componentType: EComponentType;
  74981. max?: number[];
  74982. min?: number[];
  74983. name?: string;
  74984. }
  74985. /** @hidden */
  74986. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74987. buffer: string;
  74988. byteOffset: number;
  74989. byteLength: number;
  74990. byteStride: number;
  74991. target?: number;
  74992. }
  74993. /** @hidden */
  74994. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74995. uri: string;
  74996. byteLength?: number;
  74997. type?: string;
  74998. }
  74999. /** @hidden */
  75000. export interface IGLTFShader extends IGLTFChildRootProperty {
  75001. uri: string;
  75002. type: EShaderType;
  75003. }
  75004. /** @hidden */
  75005. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75006. attributes: string[];
  75007. fragmentShader: string;
  75008. vertexShader: string;
  75009. }
  75010. /** @hidden */
  75011. export interface IGLTFTechniqueParameter {
  75012. type: number;
  75013. count?: number;
  75014. semantic?: string;
  75015. node?: string;
  75016. value?: number | boolean | string | Array<any>;
  75017. source?: string;
  75018. babylonValue?: any;
  75019. }
  75020. /** @hidden */
  75021. export interface IGLTFTechniqueCommonProfile {
  75022. lightingModel: string;
  75023. texcoordBindings: Object;
  75024. parameters?: Array<any>;
  75025. }
  75026. /** @hidden */
  75027. export interface IGLTFTechniqueStatesFunctions {
  75028. blendColor?: number[];
  75029. blendEquationSeparate?: number[];
  75030. blendFuncSeparate?: number[];
  75031. colorMask: boolean[];
  75032. cullFace: number[];
  75033. }
  75034. /** @hidden */
  75035. export interface IGLTFTechniqueStates {
  75036. enable: number[];
  75037. functions: IGLTFTechniqueStatesFunctions;
  75038. }
  75039. /** @hidden */
  75040. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75041. parameters: {
  75042. [key: string]: IGLTFTechniqueParameter;
  75043. };
  75044. program: string;
  75045. attributes: {
  75046. [key: string]: string;
  75047. };
  75048. uniforms: {
  75049. [key: string]: string;
  75050. };
  75051. states: IGLTFTechniqueStates;
  75052. }
  75053. /** @hidden */
  75054. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75055. technique?: string;
  75056. values: string[];
  75057. }
  75058. /** @hidden */
  75059. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75060. attributes: {
  75061. [key: string]: string;
  75062. };
  75063. indices: string;
  75064. material: string;
  75065. mode?: number;
  75066. }
  75067. /** @hidden */
  75068. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75069. primitives: IGLTFMeshPrimitive[];
  75070. }
  75071. /** @hidden */
  75072. export interface IGLTFImage extends IGLTFChildRootProperty {
  75073. uri: string;
  75074. }
  75075. /** @hidden */
  75076. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75077. magFilter?: number;
  75078. minFilter?: number;
  75079. wrapS?: number;
  75080. wrapT?: number;
  75081. }
  75082. /** @hidden */
  75083. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75084. sampler: string;
  75085. source: string;
  75086. format?: ETextureFormat;
  75087. internalFormat?: ETextureFormat;
  75088. target?: number;
  75089. type?: number;
  75090. babylonTexture?: Texture;
  75091. }
  75092. /** @hidden */
  75093. export interface IGLTFAmbienLight {
  75094. color?: number[];
  75095. }
  75096. /** @hidden */
  75097. export interface IGLTFDirectionalLight {
  75098. color?: number[];
  75099. }
  75100. /** @hidden */
  75101. export interface IGLTFPointLight {
  75102. color?: number[];
  75103. constantAttenuation?: number;
  75104. linearAttenuation?: number;
  75105. quadraticAttenuation?: number;
  75106. }
  75107. /** @hidden */
  75108. export interface IGLTFSpotLight {
  75109. color?: number[];
  75110. constantAttenuation?: number;
  75111. fallOfAngle?: number;
  75112. fallOffExponent?: number;
  75113. linearAttenuation?: number;
  75114. quadraticAttenuation?: number;
  75115. }
  75116. /** @hidden */
  75117. export interface IGLTFLight extends IGLTFChildRootProperty {
  75118. type: string;
  75119. }
  75120. /** @hidden */
  75121. export interface IGLTFCameraOrthographic {
  75122. xmag: number;
  75123. ymag: number;
  75124. zfar: number;
  75125. znear: number;
  75126. }
  75127. /** @hidden */
  75128. export interface IGLTFCameraPerspective {
  75129. aspectRatio: number;
  75130. yfov: number;
  75131. zfar: number;
  75132. znear: number;
  75133. }
  75134. /** @hidden */
  75135. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75136. type: string;
  75137. }
  75138. /** @hidden */
  75139. export interface IGLTFAnimationChannelTarget {
  75140. id: string;
  75141. path: string;
  75142. }
  75143. /** @hidden */
  75144. export interface IGLTFAnimationChannel {
  75145. sampler: string;
  75146. target: IGLTFAnimationChannelTarget;
  75147. }
  75148. /** @hidden */
  75149. export interface IGLTFAnimationSampler {
  75150. input: string;
  75151. output: string;
  75152. interpolation?: string;
  75153. }
  75154. /** @hidden */
  75155. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75156. channels?: IGLTFAnimationChannel[];
  75157. parameters?: {
  75158. [key: string]: string;
  75159. };
  75160. samplers?: {
  75161. [key: string]: IGLTFAnimationSampler;
  75162. };
  75163. }
  75164. /** @hidden */
  75165. export interface IGLTFNodeInstanceSkin {
  75166. skeletons: string[];
  75167. skin: string;
  75168. meshes: string[];
  75169. }
  75170. /** @hidden */
  75171. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75172. bindShapeMatrix: number[];
  75173. inverseBindMatrices: string;
  75174. jointNames: string[];
  75175. babylonSkeleton?: Skeleton;
  75176. }
  75177. /** @hidden */
  75178. export interface IGLTFNode extends IGLTFChildRootProperty {
  75179. camera?: string;
  75180. children: string[];
  75181. skin?: string;
  75182. jointName?: string;
  75183. light?: string;
  75184. matrix: number[];
  75185. mesh?: string;
  75186. meshes?: string[];
  75187. rotation?: number[];
  75188. scale?: number[];
  75189. translation?: number[];
  75190. babylonNode?: Node;
  75191. }
  75192. /** @hidden */
  75193. export interface IGLTFScene extends IGLTFChildRootProperty {
  75194. nodes: string[];
  75195. }
  75196. /** @hidden */
  75197. export interface IGLTFRuntime {
  75198. extensions: {
  75199. [key: string]: any;
  75200. };
  75201. accessors: {
  75202. [key: string]: IGLTFAccessor;
  75203. };
  75204. buffers: {
  75205. [key: string]: IGLTFBuffer;
  75206. };
  75207. bufferViews: {
  75208. [key: string]: IGLTFBufferView;
  75209. };
  75210. meshes: {
  75211. [key: string]: IGLTFMesh;
  75212. };
  75213. lights: {
  75214. [key: string]: IGLTFLight;
  75215. };
  75216. cameras: {
  75217. [key: string]: IGLTFCamera;
  75218. };
  75219. nodes: {
  75220. [key: string]: IGLTFNode;
  75221. };
  75222. images: {
  75223. [key: string]: IGLTFImage;
  75224. };
  75225. textures: {
  75226. [key: string]: IGLTFTexture;
  75227. };
  75228. shaders: {
  75229. [key: string]: IGLTFShader;
  75230. };
  75231. programs: {
  75232. [key: string]: IGLTFProgram;
  75233. };
  75234. samplers: {
  75235. [key: string]: IGLTFSampler;
  75236. };
  75237. techniques: {
  75238. [key: string]: IGLTFTechnique;
  75239. };
  75240. materials: {
  75241. [key: string]: IGLTFMaterial;
  75242. };
  75243. animations: {
  75244. [key: string]: IGLTFAnimation;
  75245. };
  75246. skins: {
  75247. [key: string]: IGLTFSkins;
  75248. };
  75249. currentScene?: Object;
  75250. scenes: {
  75251. [key: string]: IGLTFScene;
  75252. };
  75253. extensionsUsed: string[];
  75254. extensionsRequired?: string[];
  75255. buffersCount: number;
  75256. shaderscount: number;
  75257. scene: Scene;
  75258. rootUrl: string;
  75259. loadedBufferCount: number;
  75260. loadedBufferViews: {
  75261. [name: string]: ArrayBufferView;
  75262. };
  75263. loadedShaderCount: number;
  75264. importOnlyMeshes: boolean;
  75265. importMeshesNames?: string[];
  75266. dummyNodes: Node[];
  75267. forAssetContainer: boolean;
  75268. }
  75269. /** @hidden */
  75270. export interface INodeToRoot {
  75271. bone: Bone;
  75272. node: IGLTFNode;
  75273. id: string;
  75274. }
  75275. /** @hidden */
  75276. export interface IJointNode {
  75277. node: IGLTFNode;
  75278. id: string;
  75279. }
  75280. }
  75281. declare module BABYLON.GLTF1 {
  75282. /**
  75283. * Utils functions for GLTF
  75284. * @hidden
  75285. */
  75286. export class GLTFUtils {
  75287. /**
  75288. * Sets the given "parameter" matrix
  75289. * @param scene: the Scene object
  75290. * @param source: the source node where to pick the matrix
  75291. * @param parameter: the GLTF technique parameter
  75292. * @param uniformName: the name of the shader's uniform
  75293. * @param shaderMaterial: the shader material
  75294. */
  75295. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75296. /**
  75297. * Sets the given "parameter" matrix
  75298. * @param shaderMaterial: the shader material
  75299. * @param uniform: the name of the shader's uniform
  75300. * @param value: the value of the uniform
  75301. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75302. */
  75303. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75304. /**
  75305. * Returns the wrap mode of the texture
  75306. * @param mode: the mode value
  75307. */
  75308. static GetWrapMode(mode: number): number;
  75309. /**
  75310. * Returns the byte stride giving an accessor
  75311. * @param accessor: the GLTF accessor objet
  75312. */
  75313. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75314. /**
  75315. * Returns the texture filter mode giving a mode value
  75316. * @param mode: the filter mode value
  75317. */
  75318. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75319. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75320. /**
  75321. * Returns a buffer from its accessor
  75322. * @param gltfRuntime: the GLTF runtime
  75323. * @param accessor: the GLTF accessor
  75324. */
  75325. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75326. /**
  75327. * Decodes a buffer view into a string
  75328. * @param view: the buffer view
  75329. */
  75330. static DecodeBufferToText(view: ArrayBufferView): string;
  75331. /**
  75332. * Returns the default material of gltf. Related to
  75333. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75334. * @param scene: the Babylon.js scene
  75335. */
  75336. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75337. private static _DefaultMaterial;
  75338. }
  75339. }
  75340. declare module BABYLON.GLTF1 {
  75341. /**
  75342. * Implementation of the base glTF spec
  75343. * @hidden
  75344. */
  75345. export class GLTFLoaderBase {
  75346. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75347. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75348. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75349. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75350. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75351. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75352. }
  75353. /**
  75354. * glTF V1 Loader
  75355. * @hidden
  75356. */
  75357. export class GLTFLoader implements IGLTFLoader {
  75358. static Extensions: {
  75359. [name: string]: GLTFLoaderExtension;
  75360. };
  75361. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75362. state: Nullable<GLTFLoaderState>;
  75363. dispose(): void;
  75364. private _importMeshAsync;
  75365. /**
  75366. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75367. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75368. * @param scene the scene the meshes should be added to
  75369. * @param forAssetContainer defines if the entities must be stored in the scene
  75370. * @param data gltf data containing information of the meshes in a loaded file
  75371. * @param rootUrl root url to load from
  75372. * @param onProgress event that fires when loading progress has occured
  75373. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75374. */
  75375. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75376. private _loadAsync;
  75377. /**
  75378. * Imports all objects from a loaded gltf file and adds them to the scene
  75379. * @param scene the scene the objects should be added to
  75380. * @param data gltf data containing information of the meshes in a loaded file
  75381. * @param rootUrl root url to load from
  75382. * @param onProgress event that fires when loading progress has occured
  75383. * @returns a promise which completes when objects have been loaded to the scene
  75384. */
  75385. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75386. private _loadShadersAsync;
  75387. private _loadBuffersAsync;
  75388. private _createNodes;
  75389. }
  75390. /** @hidden */
  75391. export abstract class GLTFLoaderExtension {
  75392. private _name;
  75393. constructor(name: string);
  75394. get name(): string;
  75395. /**
  75396. * Defines an override for loading the runtime
  75397. * Return true to stop further extensions from loading the runtime
  75398. */
  75399. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75400. /**
  75401. * Defines an onverride for creating gltf runtime
  75402. * Return true to stop further extensions from creating the runtime
  75403. */
  75404. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75405. /**
  75406. * Defines an override for loading buffers
  75407. * Return true to stop further extensions from loading this buffer
  75408. */
  75409. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75410. /**
  75411. * Defines an override for loading texture buffers
  75412. * Return true to stop further extensions from loading this texture data
  75413. */
  75414. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75415. /**
  75416. * Defines an override for creating textures
  75417. * Return true to stop further extensions from loading this texture
  75418. */
  75419. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75420. /**
  75421. * Defines an override for loading shader strings
  75422. * Return true to stop further extensions from loading this shader data
  75423. */
  75424. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75425. /**
  75426. * Defines an override for loading materials
  75427. * Return true to stop further extensions from loading this material
  75428. */
  75429. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75430. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75431. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75432. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75433. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75434. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75435. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75436. private static LoadTextureBufferAsync;
  75437. private static CreateTextureAsync;
  75438. private static ApplyExtensions;
  75439. }
  75440. }
  75441. declare module BABYLON.GLTF1 {
  75442. /** @hidden */
  75443. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75444. private _bin;
  75445. constructor();
  75446. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75447. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75448. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75449. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75450. }
  75451. }
  75452. declare module BABYLON.GLTF1 {
  75453. /** @hidden */
  75454. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75455. constructor();
  75456. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75457. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75458. private _loadTexture;
  75459. }
  75460. }
  75461. declare module BABYLON.GLTF2.Loader {
  75462. /**
  75463. * Loader interface with an index field.
  75464. */
  75465. export interface IArrayItem {
  75466. /**
  75467. * The index of this item in the array.
  75468. */
  75469. index: number;
  75470. }
  75471. /**
  75472. * Loader interface with additional members.
  75473. */
  75474. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75475. /** @hidden */
  75476. _data?: Promise<ArrayBufferView>;
  75477. /** @hidden */
  75478. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75479. }
  75480. /**
  75481. * Loader interface with additional members.
  75482. */
  75483. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75484. }
  75485. /** @hidden */
  75486. export interface _IAnimationSamplerData {
  75487. input: Float32Array;
  75488. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75489. output: Float32Array;
  75490. }
  75491. /**
  75492. * Loader interface with additional members.
  75493. */
  75494. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75495. /** @hidden */
  75496. _data?: Promise<_IAnimationSamplerData>;
  75497. }
  75498. /**
  75499. * Loader interface with additional members.
  75500. */
  75501. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75502. channels: IAnimationChannel[];
  75503. samplers: IAnimationSampler[];
  75504. /** @hidden */
  75505. _babylonAnimationGroup?: AnimationGroup;
  75506. }
  75507. /**
  75508. * Loader interface with additional members.
  75509. */
  75510. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75511. /** @hidden */
  75512. _data?: Promise<ArrayBufferView>;
  75513. }
  75514. /**
  75515. * Loader interface with additional members.
  75516. */
  75517. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75518. /** @hidden */
  75519. _data?: Promise<ArrayBufferView>;
  75520. /** @hidden */
  75521. _babylonBuffer?: Promise<Buffer>;
  75522. }
  75523. /**
  75524. * Loader interface with additional members.
  75525. */
  75526. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75527. }
  75528. /**
  75529. * Loader interface with additional members.
  75530. */
  75531. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75532. /** @hidden */
  75533. _data?: Promise<ArrayBufferView>;
  75534. }
  75535. /**
  75536. * Loader interface with additional members.
  75537. */
  75538. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75539. }
  75540. /**
  75541. * Loader interface with additional members.
  75542. */
  75543. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75544. }
  75545. /**
  75546. * Loader interface with additional members.
  75547. */
  75548. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75549. baseColorTexture?: ITextureInfo;
  75550. metallicRoughnessTexture?: ITextureInfo;
  75551. }
  75552. /**
  75553. * Loader interface with additional members.
  75554. */
  75555. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75556. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75557. normalTexture?: IMaterialNormalTextureInfo;
  75558. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75559. emissiveTexture?: ITextureInfo;
  75560. /** @hidden */
  75561. _data?: {
  75562. [babylonDrawMode: number]: {
  75563. babylonMaterial: Material;
  75564. babylonMeshes: AbstractMesh[];
  75565. promise: Promise<void>;
  75566. };
  75567. };
  75568. }
  75569. /**
  75570. * Loader interface with additional members.
  75571. */
  75572. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75573. primitives: IMeshPrimitive[];
  75574. }
  75575. /**
  75576. * Loader interface with additional members.
  75577. */
  75578. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75579. /** @hidden */
  75580. _instanceData?: {
  75581. babylonSourceMesh: Mesh;
  75582. promise: Promise<any>;
  75583. };
  75584. }
  75585. /**
  75586. * Loader interface with additional members.
  75587. */
  75588. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75589. /**
  75590. * The parent glTF node.
  75591. */
  75592. parent?: INode;
  75593. /** @hidden */
  75594. _babylonTransformNode?: TransformNode;
  75595. /** @hidden */
  75596. _primitiveBabylonMeshes?: AbstractMesh[];
  75597. /** @hidden */
  75598. _babylonBones?: Bone[];
  75599. /** @hidden */
  75600. _numMorphTargets?: number;
  75601. }
  75602. /** @hidden */
  75603. export interface _ISamplerData {
  75604. noMipMaps: boolean;
  75605. samplingMode: number;
  75606. wrapU: number;
  75607. wrapV: number;
  75608. }
  75609. /**
  75610. * Loader interface with additional members.
  75611. */
  75612. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75613. /** @hidden */
  75614. _data?: _ISamplerData;
  75615. }
  75616. /**
  75617. * Loader interface with additional members.
  75618. */
  75619. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75620. }
  75621. /**
  75622. * Loader interface with additional members.
  75623. */
  75624. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75625. /** @hidden */
  75626. _data?: {
  75627. babylonSkeleton: Skeleton;
  75628. promise: Promise<void>;
  75629. };
  75630. }
  75631. /**
  75632. * Loader interface with additional members.
  75633. */
  75634. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75635. }
  75636. /**
  75637. * Loader interface with additional members.
  75638. */
  75639. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75640. }
  75641. /**
  75642. * Loader interface with additional members.
  75643. */
  75644. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75645. accessors?: IAccessor[];
  75646. animations?: IAnimation[];
  75647. buffers?: IBuffer[];
  75648. bufferViews?: IBufferView[];
  75649. cameras?: ICamera[];
  75650. images?: IImage[];
  75651. materials?: IMaterial[];
  75652. meshes?: IMesh[];
  75653. nodes?: INode[];
  75654. samplers?: ISampler[];
  75655. scenes?: IScene[];
  75656. skins?: ISkin[];
  75657. textures?: ITexture[];
  75658. }
  75659. }
  75660. declare module BABYLON.GLTF2 {
  75661. /**
  75662. * Interface for a glTF loader extension.
  75663. */
  75664. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75665. /**
  75666. * Called after the loader state changes to LOADING.
  75667. */
  75668. onLoading?(): void;
  75669. /**
  75670. * Called after the loader state changes to READY.
  75671. */
  75672. onReady?(): void;
  75673. /**
  75674. * Define this method to modify the default behavior when loading scenes.
  75675. * @param context The context when loading the asset
  75676. * @param scene The glTF scene property
  75677. * @returns A promise that resolves when the load is complete or null if not handled
  75678. */
  75679. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75680. /**
  75681. * Define this method to modify the default behavior when loading nodes.
  75682. * @param context The context when loading the asset
  75683. * @param node The glTF node property
  75684. * @param assign A function called synchronously after parsing the glTF properties
  75685. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75686. */
  75687. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75688. /**
  75689. * Define this method to modify the default behavior when loading cameras.
  75690. * @param context The context when loading the asset
  75691. * @param camera The glTF camera property
  75692. * @param assign A function called synchronously after parsing the glTF properties
  75693. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75694. */
  75695. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75696. /**
  75697. * @hidden
  75698. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75699. * @param context The context when loading the asset
  75700. * @param primitive The glTF mesh primitive property
  75701. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75702. */
  75703. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75704. /**
  75705. * @hidden
  75706. * Define this method to modify the default behavior when loading data for mesh primitives.
  75707. * @param context The context when loading the asset
  75708. * @param name The mesh name when loading the asset
  75709. * @param node The glTF node when loading the asset
  75710. * @param mesh The glTF mesh when loading the asset
  75711. * @param primitive The glTF mesh primitive property
  75712. * @param assign A function called synchronously after parsing the glTF properties
  75713. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75714. */
  75715. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75716. /**
  75717. * @hidden
  75718. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75719. * @param context The context when loading the asset
  75720. * @param material The glTF material property
  75721. * @param assign A function called synchronously after parsing the glTF properties
  75722. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75723. */
  75724. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75725. /**
  75726. * Define this method to modify the default behavior when creating materials.
  75727. * @param context The context when loading the asset
  75728. * @param material The glTF material property
  75729. * @param babylonDrawMode The draw mode for the Babylon material
  75730. * @returns The Babylon material or null if not handled
  75731. */
  75732. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75733. /**
  75734. * Define this method to modify the default behavior when loading material properties.
  75735. * @param context The context when loading the asset
  75736. * @param material The glTF material property
  75737. * @param babylonMaterial The Babylon material
  75738. * @returns A promise that resolves when the load is complete or null if not handled
  75739. */
  75740. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75741. /**
  75742. * Define this method to modify the default behavior when loading texture infos.
  75743. * @param context The context when loading the asset
  75744. * @param textureInfo The glTF texture info property
  75745. * @param assign A function called synchronously after parsing the glTF properties
  75746. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75747. */
  75748. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75749. /**
  75750. * @hidden
  75751. * Define this method to modify the default behavior when loading textures.
  75752. * @param context The context when loading the asset
  75753. * @param texture The glTF texture property
  75754. * @param assign A function called synchronously after parsing the glTF properties
  75755. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75756. */
  75757. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75758. /**
  75759. * Define this method to modify the default behavior when loading animations.
  75760. * @param context The context when loading the asset
  75761. * @param animation The glTF animation property
  75762. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75763. */
  75764. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75765. /**
  75766. * @hidden
  75767. * Define this method to modify the default behavior when loading skins.
  75768. * @param context The context when loading the asset
  75769. * @param node The glTF node property
  75770. * @param skin The glTF skin property
  75771. * @returns A promise that resolves when the load is complete or null if not handled
  75772. */
  75773. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75774. /**
  75775. * @hidden
  75776. * Define this method to modify the default behavior when loading uris.
  75777. * @param context The context when loading the asset
  75778. * @param property The glTF property associated with the uri
  75779. * @param uri The uri to load
  75780. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75781. */
  75782. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75783. /**
  75784. * Define this method to modify the default behavior when loading buffer views.
  75785. * @param context The context when loading the asset
  75786. * @param bufferView The glTF buffer view property
  75787. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75788. */
  75789. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75790. /**
  75791. * Define this method to modify the default behavior when loading buffers.
  75792. * @param context The context when loading the asset
  75793. * @param buffer The glTF buffer property
  75794. * @param byteOffset The byte offset to load
  75795. * @param byteLength The byte length to load
  75796. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75797. */
  75798. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75799. }
  75800. }
  75801. declare module BABYLON.GLTF2 {
  75802. /**
  75803. * Helper class for working with arrays when loading the glTF asset
  75804. */
  75805. export class ArrayItem {
  75806. /**
  75807. * Gets an item from the given array.
  75808. * @param context The context when loading the asset
  75809. * @param array The array to get the item from
  75810. * @param index The index to the array
  75811. * @returns The array item
  75812. */
  75813. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75814. /**
  75815. * Assign an `index` field to each item of the given array.
  75816. * @param array The array of items
  75817. */
  75818. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75819. }
  75820. /**
  75821. * The glTF 2.0 loader
  75822. */
  75823. export class GLTFLoader implements IGLTFLoader {
  75824. /** @hidden */
  75825. _completePromises: Promise<any>[];
  75826. /** @hidden */
  75827. _forAssetContainer: boolean;
  75828. /** Storage */
  75829. _babylonLights: Light[];
  75830. private _disposed;
  75831. private _parent;
  75832. private _state;
  75833. private _extensions;
  75834. private _rootUrl;
  75835. private _fileName;
  75836. private _uniqueRootUrl;
  75837. private _gltf;
  75838. private _bin;
  75839. private _babylonScene;
  75840. private _rootBabylonMesh;
  75841. private _defaultBabylonMaterialData;
  75842. private _progressCallback?;
  75843. private _requests;
  75844. private static _RegisteredExtensions;
  75845. /**
  75846. * The default glTF sampler.
  75847. */
  75848. static readonly DefaultSampler: ISampler;
  75849. /**
  75850. * Registers a loader extension.
  75851. * @param name The name of the loader extension.
  75852. * @param factory The factory function that creates the loader extension.
  75853. */
  75854. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75855. /**
  75856. * Unregisters a loader extension.
  75857. * @param name The name of the loader extension.
  75858. * @returns A boolean indicating whether the extension has been unregistered
  75859. */
  75860. static UnregisterExtension(name: string): boolean;
  75861. /**
  75862. * The loader state.
  75863. */
  75864. get state(): Nullable<GLTFLoaderState>;
  75865. /**
  75866. * The object that represents the glTF JSON.
  75867. */
  75868. get gltf(): IGLTF;
  75869. /**
  75870. * The BIN chunk of a binary glTF.
  75871. */
  75872. get bin(): Nullable<IDataBuffer>;
  75873. /**
  75874. * The parent file loader.
  75875. */
  75876. get parent(): GLTFFileLoader;
  75877. /**
  75878. * The Babylon scene when loading the asset.
  75879. */
  75880. get babylonScene(): Scene;
  75881. /**
  75882. * The root Babylon mesh when loading the asset.
  75883. */
  75884. get rootBabylonMesh(): Mesh;
  75885. /** @hidden */
  75886. constructor(parent: GLTFFileLoader);
  75887. /** @hidden */
  75888. dispose(): void;
  75889. /** @hidden */
  75890. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75891. /** @hidden */
  75892. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75893. private _loadAsync;
  75894. private _loadData;
  75895. private _setupData;
  75896. private _loadExtensions;
  75897. private _checkExtensions;
  75898. private _setState;
  75899. private _createRootNode;
  75900. /**
  75901. * Loads a glTF scene.
  75902. * @param context The context when loading the asset
  75903. * @param scene The glTF scene property
  75904. * @returns A promise that resolves when the load is complete
  75905. */
  75906. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75907. private _forEachPrimitive;
  75908. private _getMeshes;
  75909. private _getTransformNodes;
  75910. private _getSkeletons;
  75911. private _getAnimationGroups;
  75912. private _startAnimations;
  75913. /**
  75914. * Loads a glTF node.
  75915. * @param context The context when loading the asset
  75916. * @param node The glTF node property
  75917. * @param assign A function called synchronously after parsing the glTF properties
  75918. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75919. */
  75920. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75921. private _loadMeshAsync;
  75922. /**
  75923. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75924. * @param context The context when loading the asset
  75925. * @param name The mesh name when loading the asset
  75926. * @param node The glTF node when loading the asset
  75927. * @param mesh The glTF mesh when loading the asset
  75928. * @param primitive The glTF mesh primitive property
  75929. * @param assign A function called synchronously after parsing the glTF properties
  75930. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75931. */
  75932. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75933. private _loadVertexDataAsync;
  75934. private _createMorphTargets;
  75935. private _loadMorphTargetsAsync;
  75936. private _loadMorphTargetVertexDataAsync;
  75937. private static _LoadTransform;
  75938. private _loadSkinAsync;
  75939. private _loadBones;
  75940. private _loadBone;
  75941. private _loadSkinInverseBindMatricesDataAsync;
  75942. private _updateBoneMatrices;
  75943. private _getNodeMatrix;
  75944. /**
  75945. * Loads a glTF camera.
  75946. * @param context The context when loading the asset
  75947. * @param camera The glTF camera property
  75948. * @param assign A function called synchronously after parsing the glTF properties
  75949. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75950. */
  75951. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75952. private _loadAnimationsAsync;
  75953. /**
  75954. * Loads a glTF animation.
  75955. * @param context The context when loading the asset
  75956. * @param animation The glTF animation property
  75957. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75958. */
  75959. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75960. /**
  75961. * @hidden Loads a glTF animation channel.
  75962. * @param context The context when loading the asset
  75963. * @param animationContext The context of the animation when loading the asset
  75964. * @param animation The glTF animation property
  75965. * @param channel The glTF animation channel property
  75966. * @param babylonAnimationGroup The babylon animation group property
  75967. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75968. * @returns A void promise when the channel load is complete
  75969. */
  75970. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75971. private _loadAnimationSamplerAsync;
  75972. private _loadBufferAsync;
  75973. /**
  75974. * Loads a glTF buffer view.
  75975. * @param context The context when loading the asset
  75976. * @param bufferView The glTF buffer view property
  75977. * @returns A promise that resolves with the loaded data when the load is complete
  75978. */
  75979. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75980. private _loadAccessorAsync;
  75981. /** @hidden */
  75982. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  75983. private _loadIndicesAccessorAsync;
  75984. private _loadVertexBufferViewAsync;
  75985. private _loadVertexAccessorAsync;
  75986. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75987. /** @hidden */
  75988. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75989. private _createDefaultMaterial;
  75990. /**
  75991. * Creates a Babylon material from a glTF material.
  75992. * @param context The context when loading the asset
  75993. * @param material The glTF material property
  75994. * @param babylonDrawMode The draw mode for the Babylon material
  75995. * @returns The Babylon material
  75996. */
  75997. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75998. /**
  75999. * Loads properties from a glTF material into a Babylon material.
  76000. * @param context The context when loading the asset
  76001. * @param material The glTF material property
  76002. * @param babylonMaterial The Babylon material
  76003. * @returns A promise that resolves when the load is complete
  76004. */
  76005. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76006. /**
  76007. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76008. * @param context The context when loading the asset
  76009. * @param material The glTF material property
  76010. * @param babylonMaterial The Babylon material
  76011. * @returns A promise that resolves when the load is complete
  76012. */
  76013. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76014. /**
  76015. * Loads the alpha properties from a glTF material into a Babylon material.
  76016. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76017. * @param context The context when loading the asset
  76018. * @param material The glTF material property
  76019. * @param babylonMaterial The Babylon material
  76020. */
  76021. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76022. /**
  76023. * Loads a glTF texture info.
  76024. * @param context The context when loading the asset
  76025. * @param textureInfo The glTF texture info property
  76026. * @param assign A function called synchronously after parsing the glTF properties
  76027. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76028. */
  76029. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76030. /** @hidden */
  76031. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76032. /** @hidden */
  76033. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76034. private _loadSampler;
  76035. /**
  76036. * Loads a glTF image.
  76037. * @param context The context when loading the asset
  76038. * @param image The glTF image property
  76039. * @returns A promise that resolves with the loaded data when the load is complete
  76040. */
  76041. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76042. /**
  76043. * Loads a glTF uri.
  76044. * @param context The context when loading the asset
  76045. * @param property The glTF property associated with the uri
  76046. * @param uri The base64 or relative uri
  76047. * @returns A promise that resolves with the loaded data when the load is complete
  76048. */
  76049. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76050. private _onProgress;
  76051. /**
  76052. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76053. * @param babylonObject the Babylon object with metadata
  76054. * @param pointer the JSON pointer
  76055. */
  76056. static AddPointerMetadata(babylonObject: {
  76057. metadata: any;
  76058. }, pointer: string): void;
  76059. private static _GetTextureWrapMode;
  76060. private static _GetTextureSamplingMode;
  76061. private static _GetTypedArrayConstructor;
  76062. private static _GetTypedArray;
  76063. private static _GetNumComponents;
  76064. private static _ValidateUri;
  76065. private static _GetDrawMode;
  76066. private _compileMaterialsAsync;
  76067. private _compileShadowGeneratorsAsync;
  76068. private _forEachExtensions;
  76069. private _applyExtensions;
  76070. private _extensionsOnLoading;
  76071. private _extensionsOnReady;
  76072. private _extensionsLoadSceneAsync;
  76073. private _extensionsLoadNodeAsync;
  76074. private _extensionsLoadCameraAsync;
  76075. private _extensionsLoadVertexDataAsync;
  76076. private _extensionsLoadMeshPrimitiveAsync;
  76077. private _extensionsLoadMaterialAsync;
  76078. private _extensionsCreateMaterial;
  76079. private _extensionsLoadMaterialPropertiesAsync;
  76080. private _extensionsLoadTextureInfoAsync;
  76081. private _extensionsLoadTextureAsync;
  76082. private _extensionsLoadAnimationAsync;
  76083. private _extensionsLoadSkinAsync;
  76084. private _extensionsLoadUriAsync;
  76085. private _extensionsLoadBufferViewAsync;
  76086. private _extensionsLoadBufferAsync;
  76087. /**
  76088. * Helper method called by a loader extension to load an glTF extension.
  76089. * @param context The context when loading the asset
  76090. * @param property The glTF property to load the extension from
  76091. * @param extensionName The name of the extension to load
  76092. * @param actionAsync The action to run
  76093. * @returns The promise returned by actionAsync or null if the extension does not exist
  76094. */
  76095. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76096. /**
  76097. * Helper method called by a loader extension to load a glTF extra.
  76098. * @param context The context when loading the asset
  76099. * @param property The glTF property to load the extra from
  76100. * @param extensionName The name of the extension to load
  76101. * @param actionAsync The action to run
  76102. * @returns The promise returned by actionAsync or null if the extra does not exist
  76103. */
  76104. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76105. /**
  76106. * Checks for presence of an extension.
  76107. * @param name The name of the extension to check
  76108. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76109. */
  76110. isExtensionUsed(name: string): boolean;
  76111. /**
  76112. * Increments the indentation level and logs a message.
  76113. * @param message The message to log
  76114. */
  76115. logOpen(message: string): void;
  76116. /**
  76117. * Decrements the indentation level.
  76118. */
  76119. logClose(): void;
  76120. /**
  76121. * Logs a message
  76122. * @param message The message to log
  76123. */
  76124. log(message: string): void;
  76125. /**
  76126. * Starts a performance counter.
  76127. * @param counterName The name of the performance counter
  76128. */
  76129. startPerformanceCounter(counterName: string): void;
  76130. /**
  76131. * Ends a performance counter.
  76132. * @param counterName The name of the performance counter
  76133. */
  76134. endPerformanceCounter(counterName: string): void;
  76135. }
  76136. }
  76137. declare module BABYLON.GLTF2.Loader.Extensions {
  76138. /**
  76139. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76140. */
  76141. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76142. /**
  76143. * The name of this extension.
  76144. */
  76145. readonly name: string;
  76146. /**
  76147. * Defines whether this extension is enabled.
  76148. */
  76149. enabled: boolean;
  76150. private _loader;
  76151. private _lights?;
  76152. /** @hidden */
  76153. constructor(loader: GLTFLoader);
  76154. /** @hidden */
  76155. dispose(): void;
  76156. /** @hidden */
  76157. onLoading(): void;
  76158. /** @hidden */
  76159. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76160. private _loadLightAsync;
  76161. }
  76162. }
  76163. declare module BABYLON.GLTF2.Loader.Extensions {
  76164. /**
  76165. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76166. */
  76167. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76168. /**
  76169. * The name of this extension.
  76170. */
  76171. readonly name: string;
  76172. /**
  76173. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76174. */
  76175. dracoCompression?: DracoCompression;
  76176. /**
  76177. * Defines whether this extension is enabled.
  76178. */
  76179. enabled: boolean;
  76180. private _loader;
  76181. /** @hidden */
  76182. constructor(loader: GLTFLoader);
  76183. /** @hidden */
  76184. dispose(): void;
  76185. /** @hidden */
  76186. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76187. }
  76188. }
  76189. declare module BABYLON.GLTF2.Loader.Extensions {
  76190. /**
  76191. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76192. */
  76193. export class KHR_lights implements IGLTFLoaderExtension {
  76194. /**
  76195. * The name of this extension.
  76196. */
  76197. readonly name: string;
  76198. /**
  76199. * Defines whether this extension is enabled.
  76200. */
  76201. enabled: boolean;
  76202. private _loader;
  76203. private _lights?;
  76204. /** @hidden */
  76205. constructor(loader: GLTFLoader);
  76206. /** @hidden */
  76207. dispose(): void;
  76208. /** @hidden */
  76209. onLoading(): void;
  76210. /** @hidden */
  76211. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76212. }
  76213. }
  76214. declare module BABYLON.GLTF2.Loader.Extensions {
  76215. /**
  76216. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76217. */
  76218. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76219. /**
  76220. * The name of this extension.
  76221. */
  76222. readonly name: string;
  76223. /**
  76224. * Defines whether this extension is enabled.
  76225. */
  76226. enabled: boolean;
  76227. /**
  76228. * Defines a number that determines the order the extensions are applied.
  76229. */
  76230. order: number;
  76231. private _loader;
  76232. /** @hidden */
  76233. constructor(loader: GLTFLoader);
  76234. /** @hidden */
  76235. dispose(): void;
  76236. /** @hidden */
  76237. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76238. private _loadSpecularGlossinessPropertiesAsync;
  76239. }
  76240. }
  76241. declare module BABYLON.GLTF2.Loader.Extensions {
  76242. /**
  76243. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76244. */
  76245. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76246. /**
  76247. * The name of this extension.
  76248. */
  76249. readonly name: string;
  76250. /**
  76251. * Defines whether this extension is enabled.
  76252. */
  76253. enabled: boolean;
  76254. /**
  76255. * Defines a number that determines the order the extensions are applied.
  76256. */
  76257. order: number;
  76258. private _loader;
  76259. /** @hidden */
  76260. constructor(loader: GLTFLoader);
  76261. /** @hidden */
  76262. dispose(): void;
  76263. /** @hidden */
  76264. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76265. private _loadUnlitPropertiesAsync;
  76266. }
  76267. }
  76268. declare module BABYLON.GLTF2.Loader.Extensions {
  76269. /**
  76270. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76271. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76272. * !!! Experimental Extension Subject to Changes !!!
  76273. */
  76274. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76275. /**
  76276. * The name of this extension.
  76277. */
  76278. readonly name: string;
  76279. /**
  76280. * Defines whether this extension is enabled.
  76281. */
  76282. enabled: boolean;
  76283. /**
  76284. * Defines a number that determines the order the extensions are applied.
  76285. */
  76286. order: number;
  76287. private _loader;
  76288. /** @hidden */
  76289. constructor(loader: GLTFLoader);
  76290. /** @hidden */
  76291. dispose(): void;
  76292. /** @hidden */
  76293. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76294. private _loadClearCoatPropertiesAsync;
  76295. }
  76296. }
  76297. declare module BABYLON.GLTF2.Loader.Extensions {
  76298. /**
  76299. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76300. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76301. * !!! Experimental Extension Subject to Changes !!!
  76302. */
  76303. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76304. /**
  76305. * The name of this extension.
  76306. */
  76307. readonly name: string;
  76308. /**
  76309. * Defines whether this extension is enabled.
  76310. */
  76311. enabled: boolean;
  76312. /**
  76313. * Defines a number that determines the order the extensions are applied.
  76314. */
  76315. order: number;
  76316. private _loader;
  76317. /** @hidden */
  76318. constructor(loader: GLTFLoader);
  76319. /** @hidden */
  76320. dispose(): void;
  76321. /** @hidden */
  76322. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76323. private _loadSheenPropertiesAsync;
  76324. }
  76325. }
  76326. declare module BABYLON.GLTF2.Loader.Extensions {
  76327. /**
  76328. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76329. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76330. * !!! Experimental Extension Subject to Changes !!!
  76331. */
  76332. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76333. /**
  76334. * The name of this extension.
  76335. */
  76336. readonly name: string;
  76337. /**
  76338. * Defines whether this extension is enabled.
  76339. */
  76340. enabled: boolean;
  76341. /**
  76342. * Defines a number that determines the order the extensions are applied.
  76343. */
  76344. order: number;
  76345. private _loader;
  76346. /** @hidden */
  76347. constructor(loader: GLTFLoader);
  76348. /** @hidden */
  76349. dispose(): void;
  76350. /** @hidden */
  76351. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76352. private _loadSpecularPropertiesAsync;
  76353. }
  76354. }
  76355. declare module BABYLON.GLTF2.Loader.Extensions {
  76356. /**
  76357. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76358. * [Playground Sample](//TODO)
  76359. * !!! Experimental Extension Subject to Changes !!!
  76360. */
  76361. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76362. /**
  76363. * The name of this extension.
  76364. */
  76365. readonly name: string;
  76366. /**
  76367. * Defines whether this extension is enabled.
  76368. */
  76369. enabled: boolean;
  76370. private _loader;
  76371. /** @hidden */
  76372. constructor(loader: GLTFLoader);
  76373. /** @hidden */
  76374. dispose(): void;
  76375. /** @hidden */
  76376. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76377. }
  76378. }
  76379. declare module BABYLON.GLTF2.Loader.Extensions {
  76380. /**
  76381. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76382. */
  76383. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76384. /**
  76385. * The name of this extension.
  76386. */
  76387. readonly name: string;
  76388. /**
  76389. * Defines whether this extension is enabled.
  76390. */
  76391. enabled: boolean;
  76392. /** @hidden */
  76393. constructor(loader: GLTFLoader);
  76394. /** @hidden */
  76395. dispose(): void;
  76396. }
  76397. }
  76398. declare module BABYLON.GLTF2.Loader.Extensions {
  76399. /**
  76400. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76401. * !!! Experimental Extension Subject to Changes !!!
  76402. */
  76403. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76404. /** The name of this extension. */
  76405. readonly name: string;
  76406. /** Defines whether this extension is enabled. */
  76407. enabled: boolean;
  76408. private _loader;
  76409. /** @hidden */
  76410. constructor(loader: GLTFLoader);
  76411. /** @hidden */
  76412. dispose(): void;
  76413. /** @hidden */
  76414. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76415. }
  76416. }
  76417. declare module BABYLON.GLTF2.Loader.Extensions {
  76418. /**
  76419. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76420. */
  76421. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76422. /**
  76423. * The name of this extension.
  76424. */
  76425. readonly name: string;
  76426. /**
  76427. * Defines whether this extension is enabled.
  76428. */
  76429. enabled: boolean;
  76430. private _loader;
  76431. /** @hidden */
  76432. constructor(loader: GLTFLoader);
  76433. /** @hidden */
  76434. dispose(): void;
  76435. /** @hidden */
  76436. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76437. }
  76438. }
  76439. declare module BABYLON.GLTF2.Loader.Extensions {
  76440. /**
  76441. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76442. */
  76443. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76444. /**
  76445. * The name of this extension.
  76446. */
  76447. readonly name: string;
  76448. /**
  76449. * Defines whether this extension is enabled.
  76450. */
  76451. enabled: boolean;
  76452. private _loader;
  76453. private _clips;
  76454. private _emitters;
  76455. /** @hidden */
  76456. constructor(loader: GLTFLoader);
  76457. /** @hidden */
  76458. dispose(): void;
  76459. /** @hidden */
  76460. onLoading(): void;
  76461. /** @hidden */
  76462. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76463. /** @hidden */
  76464. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76465. /** @hidden */
  76466. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76467. private _loadClipAsync;
  76468. private _loadEmitterAsync;
  76469. private _getEventAction;
  76470. private _loadAnimationEventAsync;
  76471. }
  76472. }
  76473. declare module BABYLON.GLTF2.Loader.Extensions {
  76474. /**
  76475. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76476. */
  76477. export class MSFT_lod implements IGLTFLoaderExtension {
  76478. /**
  76479. * The name of this extension.
  76480. */
  76481. readonly name: string;
  76482. /**
  76483. * Defines whether this extension is enabled.
  76484. */
  76485. enabled: boolean;
  76486. /**
  76487. * Defines a number that determines the order the extensions are applied.
  76488. */
  76489. order: number;
  76490. /**
  76491. * Maximum number of LODs to load, starting from the lowest LOD.
  76492. */
  76493. maxLODsToLoad: number;
  76494. /**
  76495. * Observable raised when all node LODs of one level are loaded.
  76496. * The event data is the index of the loaded LOD starting from zero.
  76497. * Dispose the loader to cancel the loading of the next level of LODs.
  76498. */
  76499. onNodeLODsLoadedObservable: Observable<number>;
  76500. /**
  76501. * Observable raised when all material LODs of one level are loaded.
  76502. * The event data is the index of the loaded LOD starting from zero.
  76503. * Dispose the loader to cancel the loading of the next level of LODs.
  76504. */
  76505. onMaterialLODsLoadedObservable: Observable<number>;
  76506. private _loader;
  76507. private _nodeIndexLOD;
  76508. private _nodeSignalLODs;
  76509. private _nodePromiseLODs;
  76510. private _materialIndexLOD;
  76511. private _materialSignalLODs;
  76512. private _materialPromiseLODs;
  76513. private _indexLOD;
  76514. private _bufferLODs;
  76515. /** @hidden */
  76516. constructor(loader: GLTFLoader);
  76517. /** @hidden */
  76518. dispose(): void;
  76519. /** @hidden */
  76520. onReady(): void;
  76521. /** @hidden */
  76522. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76523. /** @hidden */
  76524. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76525. /** @hidden */
  76526. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76527. /** @hidden */
  76528. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76529. /** @hidden */
  76530. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76531. private _loadBufferLOD;
  76532. /**
  76533. * Gets an array of LOD properties from lowest to highest.
  76534. */
  76535. private _getLODs;
  76536. private _disposeTransformNode;
  76537. private _disposeMaterials;
  76538. }
  76539. }
  76540. declare module BABYLON.GLTF2.Loader.Extensions {
  76541. /** @hidden */
  76542. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76543. readonly name: string;
  76544. enabled: boolean;
  76545. private _loader;
  76546. constructor(loader: GLTFLoader);
  76547. dispose(): void;
  76548. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76549. }
  76550. }
  76551. declare module BABYLON.GLTF2.Loader.Extensions {
  76552. /** @hidden */
  76553. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76554. readonly name: string;
  76555. enabled: boolean;
  76556. private _loader;
  76557. constructor(loader: GLTFLoader);
  76558. dispose(): void;
  76559. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76560. }
  76561. }
  76562. declare module BABYLON.GLTF2.Loader.Extensions {
  76563. /**
  76564. * Store glTF extras (if present) in BJS objects' metadata
  76565. */
  76566. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76567. /**
  76568. * The name of this extension.
  76569. */
  76570. readonly name: string;
  76571. /**
  76572. * Defines whether this extension is enabled.
  76573. */
  76574. enabled: boolean;
  76575. private _loader;
  76576. private _assignExtras;
  76577. /** @hidden */
  76578. constructor(loader: GLTFLoader);
  76579. /** @hidden */
  76580. dispose(): void;
  76581. /** @hidden */
  76582. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76583. /** @hidden */
  76584. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76585. /** @hidden */
  76586. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76587. }
  76588. }
  76589. declare module BABYLON {
  76590. /**
  76591. * Class reading and parsing the MTL file bundled with the obj file.
  76592. */
  76593. export class MTLFileLoader {
  76594. /**
  76595. * Invert Y-Axis of referenced textures on load
  76596. */
  76597. static INVERT_TEXTURE_Y: boolean;
  76598. /**
  76599. * All material loaded from the mtl will be set here
  76600. */
  76601. materials: StandardMaterial[];
  76602. /**
  76603. * This function will read the mtl file and create each material described inside
  76604. * This function could be improve by adding :
  76605. * -some component missing (Ni, Tf...)
  76606. * -including the specific options available
  76607. *
  76608. * @param scene defines the scene the material will be created in
  76609. * @param data defines the mtl data to parse
  76610. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76611. * @param forAssetContainer defines if the material should be registered in the scene
  76612. */
  76613. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76614. /**
  76615. * Gets the texture for the material.
  76616. *
  76617. * If the material is imported from input file,
  76618. * We sanitize the url to ensure it takes the textre from aside the material.
  76619. *
  76620. * @param rootUrl The root url to load from
  76621. * @param value The value stored in the mtl
  76622. * @return The Texture
  76623. */
  76624. private static _getTexture;
  76625. }
  76626. }
  76627. declare module BABYLON {
  76628. /**
  76629. * Options for loading OBJ/MTL files
  76630. */
  76631. type MeshLoadOptions = {
  76632. /**
  76633. * Defines if UVs are optimized by default during load.
  76634. */
  76635. OptimizeWithUV: boolean;
  76636. /**
  76637. * Defines custom scaling of UV coordinates of loaded meshes.
  76638. */
  76639. UVScaling: Vector2;
  76640. /**
  76641. * Invert model on y-axis (does a model scaling inversion)
  76642. */
  76643. InvertY: boolean;
  76644. /**
  76645. * Invert Y-Axis of referenced textures on load
  76646. */
  76647. InvertTextureY: boolean;
  76648. /**
  76649. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76650. */
  76651. ImportVertexColors: boolean;
  76652. /**
  76653. * Compute the normals for the model, even if normals are present in the file.
  76654. */
  76655. ComputeNormals: boolean;
  76656. /**
  76657. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76658. */
  76659. SkipMaterials: boolean;
  76660. /**
  76661. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76662. */
  76663. MaterialLoadingFailsSilently: boolean;
  76664. };
  76665. /**
  76666. * OBJ file type loader.
  76667. * This is a babylon scene loader plugin.
  76668. */
  76669. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76670. /**
  76671. * Defines if UVs are optimized by default during load.
  76672. */
  76673. static OPTIMIZE_WITH_UV: boolean;
  76674. /**
  76675. * Invert model on y-axis (does a model scaling inversion)
  76676. */
  76677. static INVERT_Y: boolean;
  76678. /**
  76679. * Invert Y-Axis of referenced textures on load
  76680. */
  76681. static get INVERT_TEXTURE_Y(): boolean;
  76682. static set INVERT_TEXTURE_Y(value: boolean);
  76683. /**
  76684. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76685. */
  76686. static IMPORT_VERTEX_COLORS: boolean;
  76687. /**
  76688. * Compute the normals for the model, even if normals are present in the file.
  76689. */
  76690. static COMPUTE_NORMALS: boolean;
  76691. /**
  76692. * Defines custom scaling of UV coordinates of loaded meshes.
  76693. */
  76694. static UV_SCALING: Vector2;
  76695. /**
  76696. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76697. */
  76698. static SKIP_MATERIALS: boolean;
  76699. /**
  76700. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76701. *
  76702. * Defaults to true for backwards compatibility.
  76703. */
  76704. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76705. /**
  76706. * Defines the name of the plugin.
  76707. */
  76708. name: string;
  76709. /**
  76710. * Defines the extension the plugin is able to load.
  76711. */
  76712. extensions: string;
  76713. /** @hidden */
  76714. obj: RegExp;
  76715. /** @hidden */
  76716. group: RegExp;
  76717. /** @hidden */
  76718. mtllib: RegExp;
  76719. /** @hidden */
  76720. usemtl: RegExp;
  76721. /** @hidden */
  76722. smooth: RegExp;
  76723. /** @hidden */
  76724. vertexPattern: RegExp;
  76725. /** @hidden */
  76726. normalPattern: RegExp;
  76727. /** @hidden */
  76728. uvPattern: RegExp;
  76729. /** @hidden */
  76730. facePattern1: RegExp;
  76731. /** @hidden */
  76732. facePattern2: RegExp;
  76733. /** @hidden */
  76734. facePattern3: RegExp;
  76735. /** @hidden */
  76736. facePattern4: RegExp;
  76737. /** @hidden */
  76738. facePattern5: RegExp;
  76739. private _forAssetContainer;
  76740. private _meshLoadOptions;
  76741. /**
  76742. * Creates loader for .OBJ files
  76743. *
  76744. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76745. */
  76746. constructor(meshLoadOptions?: MeshLoadOptions);
  76747. private static get currentMeshLoadOptions();
  76748. /**
  76749. * Calls synchronously the MTL file attached to this obj.
  76750. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76751. * Without this function materials are not displayed in the first frame (but displayed after).
  76752. * In consequence it is impossible to get material information in your HTML file
  76753. *
  76754. * @param url The URL of the MTL file
  76755. * @param rootUrl
  76756. * @param onSuccess Callback function to be called when the MTL file is loaded
  76757. * @private
  76758. */
  76759. private _loadMTL;
  76760. /**
  76761. * Instantiates a OBJ file loader plugin.
  76762. * @returns the created plugin
  76763. */
  76764. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76765. /**
  76766. * If the data string can be loaded directly.
  76767. *
  76768. * @param data string containing the file data
  76769. * @returns if the data can be loaded directly
  76770. */
  76771. canDirectLoad(data: string): boolean;
  76772. /**
  76773. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76774. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76775. * @param scene the scene the meshes should be added to
  76776. * @param data the OBJ data to load
  76777. * @param rootUrl root url to load from
  76778. * @param onProgress event that fires when loading progress has occured
  76779. * @param fileName Defines the name of the file to load
  76780. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76781. */
  76782. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76783. meshes: AbstractMesh[];
  76784. particleSystems: IParticleSystem[];
  76785. skeletons: Skeleton[];
  76786. animationGroups: AnimationGroup[];
  76787. }>;
  76788. /**
  76789. * Imports all objects from the loaded OBJ data and adds them to the scene
  76790. * @param scene the scene the objects should be added to
  76791. * @param data the OBJ data to load
  76792. * @param rootUrl root url to load from
  76793. * @param onProgress event that fires when loading progress has occured
  76794. * @param fileName Defines the name of the file to load
  76795. * @returns a promise which completes when objects have been loaded to the scene
  76796. */
  76797. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76798. /**
  76799. * Load into an asset container.
  76800. * @param scene The scene to load into
  76801. * @param data The data to import
  76802. * @param rootUrl The root url for scene and resources
  76803. * @param onProgress The callback when the load progresses
  76804. * @param fileName Defines the name of the file to load
  76805. * @returns The loaded asset container
  76806. */
  76807. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76808. /**
  76809. * Read the OBJ file and create an Array of meshes.
  76810. * Each mesh contains all information given by the OBJ and the MTL file.
  76811. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76812. *
  76813. * @param meshesNames
  76814. * @param scene Scene The scene where are displayed the data
  76815. * @param data String The content of the obj file
  76816. * @param rootUrl String The path to the folder
  76817. * @returns Array<AbstractMesh>
  76818. * @private
  76819. */
  76820. private _parseSolid;
  76821. }
  76822. }
  76823. declare module BABYLON {
  76824. /**
  76825. * STL file type loader.
  76826. * This is a babylon scene loader plugin.
  76827. */
  76828. export class STLFileLoader implements ISceneLoaderPlugin {
  76829. /** @hidden */
  76830. solidPattern: RegExp;
  76831. /** @hidden */
  76832. facetsPattern: RegExp;
  76833. /** @hidden */
  76834. normalPattern: RegExp;
  76835. /** @hidden */
  76836. vertexPattern: RegExp;
  76837. /**
  76838. * Defines the name of the plugin.
  76839. */
  76840. name: string;
  76841. /**
  76842. * Defines the extensions the stl loader is able to load.
  76843. * force data to come in as an ArrayBuffer
  76844. * we'll convert to string if it looks like it's an ASCII .stl
  76845. */
  76846. extensions: ISceneLoaderPluginExtensions;
  76847. /**
  76848. * Import meshes into a scene.
  76849. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76850. * @param scene The scene to import into
  76851. * @param data The data to import
  76852. * @param rootUrl The root url for scene and resources
  76853. * @param meshes The meshes array to import into
  76854. * @param particleSystems The particle systems array to import into
  76855. * @param skeletons The skeletons array to import into
  76856. * @param onError The callback when import fails
  76857. * @returns True if successful or false otherwise
  76858. */
  76859. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76860. /**
  76861. * Load into a scene.
  76862. * @param scene The scene to load into
  76863. * @param data The data to import
  76864. * @param rootUrl The root url for scene and resources
  76865. * @param onError The callback when import fails
  76866. * @returns true if successful or false otherwise
  76867. */
  76868. load(scene: Scene, data: any, rootUrl: string): boolean;
  76869. /**
  76870. * Load into an asset container.
  76871. * @param scene The scene to load into
  76872. * @param data The data to import
  76873. * @param rootUrl The root url for scene and resources
  76874. * @param onError The callback when import fails
  76875. * @returns The loaded asset container
  76876. */
  76877. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76878. private _isBinary;
  76879. private _parseBinary;
  76880. private _parseASCII;
  76881. }
  76882. }
  76883. declare module BABYLON {
  76884. /**
  76885. * Class for generating OBJ data from a Babylon scene.
  76886. */
  76887. export class OBJExport {
  76888. /**
  76889. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76890. * @param mesh defines the list of meshes to serialize
  76891. * @param materials defines if materials should be exported
  76892. * @param matlibname defines the name of the associated mtl file
  76893. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76894. * @returns the OBJ content
  76895. */
  76896. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76897. /**
  76898. * Exports the material(s) of a mesh in .MTL file format (text)
  76899. * @param mesh defines the mesh to extract the material from
  76900. * @returns the mtl content
  76901. */
  76902. static MTL(mesh: Mesh): string;
  76903. }
  76904. }
  76905. declare module BABYLON {
  76906. /** @hidden */
  76907. export var __IGLTFExporterExtension: number;
  76908. /**
  76909. * Interface for extending the exporter
  76910. * @hidden
  76911. */
  76912. export interface IGLTFExporterExtension {
  76913. /**
  76914. * The name of this extension
  76915. */
  76916. readonly name: string;
  76917. /**
  76918. * Defines whether this extension is enabled
  76919. */
  76920. enabled: boolean;
  76921. /**
  76922. * Defines whether this extension is required
  76923. */
  76924. required: boolean;
  76925. }
  76926. }
  76927. declare module BABYLON.GLTF2.Exporter {
  76928. /** @hidden */
  76929. export var __IGLTFExporterExtensionV2: number;
  76930. /**
  76931. * Interface for a glTF exporter extension
  76932. * @hidden
  76933. */
  76934. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76935. /**
  76936. * Define this method to modify the default behavior before exporting a texture
  76937. * @param context The context when loading the asset
  76938. * @param babylonTexture The Babylon.js texture
  76939. * @param mimeType The mime-type of the generated image
  76940. * @returns A promise that resolves with the exported texture
  76941. */
  76942. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  76943. /**
  76944. * Define this method to get notified when a texture info is created
  76945. * @param context The context when loading the asset
  76946. * @param textureInfo The glTF texture info
  76947. * @param babylonTexture The Babylon.js texture
  76948. */
  76949. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76950. /**
  76951. * Define this method to modify the default behavior when exporting texture info
  76952. * @param context The context when loading the asset
  76953. * @param meshPrimitive glTF mesh primitive
  76954. * @param babylonSubMesh Babylon submesh
  76955. * @param binaryWriter glTF serializer binary writer instance
  76956. * @returns nullable IMeshPrimitive promise
  76957. */
  76958. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76959. /**
  76960. * Define this method to modify the default behavior when exporting a node
  76961. * @param context The context when exporting the node
  76962. * @param node glTF node
  76963. * @param babylonNode BabylonJS node
  76964. * @returns nullable INode promise
  76965. */
  76966. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  76967. [key: number]: number;
  76968. }): Promise<Nullable<INode>>;
  76969. /**
  76970. * Define this method to modify the default behavior when exporting a material
  76971. * @param material glTF material
  76972. * @param babylonMaterial BabylonJS material
  76973. * @returns nullable IMaterial promise
  76974. */
  76975. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  76976. /**
  76977. * Define this method to return additional textures to export from a material
  76978. * @param material glTF material
  76979. * @param babylonMaterial BabylonJS material
  76980. * @returns List of textures
  76981. */
  76982. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76983. /** Gets a boolean indicating that this extension was used */
  76984. wasUsed: boolean;
  76985. /** Gets a boolean indicating that this extension is required for the file to work */
  76986. required: boolean;
  76987. /**
  76988. * Called after the exporter state changes to EXPORTING
  76989. */
  76990. onExporting?(): void;
  76991. }
  76992. }
  76993. declare module BABYLON.GLTF2.Exporter {
  76994. /**
  76995. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76996. * @hidden
  76997. */
  76998. export class _GLTFMaterialExporter {
  76999. /**
  77000. * Represents the dielectric specular values for R, G and B
  77001. */
  77002. private static readonly _DielectricSpecular;
  77003. /**
  77004. * Allows the maximum specular power to be defined for material calculations
  77005. */
  77006. private static readonly _MaxSpecularPower;
  77007. /**
  77008. * Mapping to store textures
  77009. */
  77010. private _textureMap;
  77011. /**
  77012. * Numeric tolerance value
  77013. */
  77014. private static readonly _Epsilon;
  77015. /**
  77016. * Reference to the glTF Exporter
  77017. */
  77018. private _exporter;
  77019. constructor(exporter: _Exporter);
  77020. /**
  77021. * Specifies if two colors are approximately equal in value
  77022. * @param color1 first color to compare to
  77023. * @param color2 second color to compare to
  77024. * @param epsilon threshold value
  77025. */
  77026. private static FuzzyEquals;
  77027. /**
  77028. * Gets the materials from a Babylon scene and converts them to glTF materials
  77029. * @param scene babylonjs scene
  77030. * @param mimeType texture mime type
  77031. * @param images array of images
  77032. * @param textures array of textures
  77033. * @param materials array of materials
  77034. * @param imageData mapping of texture names to base64 textures
  77035. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77036. */
  77037. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77038. /**
  77039. * Makes a copy of the glTF material without the texture parameters
  77040. * @param originalMaterial original glTF material
  77041. * @returns glTF material without texture parameters
  77042. */
  77043. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77044. /**
  77045. * Specifies if the material has any texture parameters present
  77046. * @param material glTF Material
  77047. * @returns boolean specifying if texture parameters are present
  77048. */
  77049. _hasTexturesPresent(material: IMaterial): boolean;
  77050. /**
  77051. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77052. * @param babylonStandardMaterial
  77053. * @returns glTF Metallic Roughness Material representation
  77054. */
  77055. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77056. /**
  77057. * Computes the metallic factor
  77058. * @param diffuse diffused value
  77059. * @param specular specular value
  77060. * @param oneMinusSpecularStrength one minus the specular strength
  77061. * @returns metallic value
  77062. */
  77063. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77064. /**
  77065. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77066. * @param glTFMaterial glTF material
  77067. * @param babylonMaterial Babylon material
  77068. */
  77069. private static _SetAlphaMode;
  77070. /**
  77071. * Converts a Babylon Standard Material to a glTF Material
  77072. * @param babylonStandardMaterial BJS Standard Material
  77073. * @param mimeType mime type to use for the textures
  77074. * @param images array of glTF image interfaces
  77075. * @param textures array of glTF texture interfaces
  77076. * @param materials array of glTF material interfaces
  77077. * @param imageData map of image file name to data
  77078. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77079. */
  77080. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77081. private _finishMaterial;
  77082. /**
  77083. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77084. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77085. * @param mimeType mime type to use for the textures
  77086. * @param images array of glTF image interfaces
  77087. * @param textures array of glTF texture interfaces
  77088. * @param materials array of glTF material interfaces
  77089. * @param imageData map of image file name to data
  77090. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77091. */
  77092. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77093. /**
  77094. * Converts an image typed array buffer to a base64 image
  77095. * @param buffer typed array buffer
  77096. * @param width width of the image
  77097. * @param height height of the image
  77098. * @param mimeType mimetype of the image
  77099. * @returns base64 image string
  77100. */
  77101. private _createBase64FromCanvasAsync;
  77102. /**
  77103. * Generates a white texture based on the specified width and height
  77104. * @param width width of the texture in pixels
  77105. * @param height height of the texture in pixels
  77106. * @param scene babylonjs scene
  77107. * @returns white texture
  77108. */
  77109. private _createWhiteTexture;
  77110. /**
  77111. * 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
  77112. * @param texture1 first texture to resize
  77113. * @param texture2 second texture to resize
  77114. * @param scene babylonjs scene
  77115. * @returns resized textures or null
  77116. */
  77117. private _resizeTexturesToSameDimensions;
  77118. /**
  77119. * Converts an array of pixels to a Float32Array
  77120. * Throws an error if the pixel format is not supported
  77121. * @param pixels - array buffer containing pixel values
  77122. * @returns Float32 of pixels
  77123. */
  77124. private _convertPixelArrayToFloat32;
  77125. /**
  77126. * Convert Specular Glossiness Textures to Metallic Roughness
  77127. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77128. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77129. * @param diffuseTexture texture used to store diffuse information
  77130. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77131. * @param factors specular glossiness material factors
  77132. * @param mimeType the mime type to use for the texture
  77133. * @returns pbr metallic roughness interface or null
  77134. */
  77135. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77136. /**
  77137. * Converts specular glossiness material properties to metallic roughness
  77138. * @param specularGlossiness interface with specular glossiness material properties
  77139. * @returns interface with metallic roughness material properties
  77140. */
  77141. private _convertSpecularGlossinessToMetallicRoughness;
  77142. /**
  77143. * Calculates the surface reflectance, independent of lighting conditions
  77144. * @param color Color source to calculate brightness from
  77145. * @returns number representing the perceived brightness, or zero if color is undefined
  77146. */
  77147. private _getPerceivedBrightness;
  77148. /**
  77149. * Returns the maximum color component value
  77150. * @param color
  77151. * @returns maximum color component value, or zero if color is null or undefined
  77152. */
  77153. private _getMaxComponent;
  77154. /**
  77155. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77156. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77157. * @param mimeType mime type to use for the textures
  77158. * @param images array of glTF image interfaces
  77159. * @param textures array of glTF texture interfaces
  77160. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77161. * @param imageData map of image file name to data
  77162. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77163. * @returns glTF PBR Metallic Roughness factors
  77164. */
  77165. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77166. private _getGLTFTextureSampler;
  77167. private _getGLTFTextureWrapMode;
  77168. private _getGLTFTextureWrapModesSampler;
  77169. /**
  77170. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77171. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77172. * @param mimeType mime type to use for the textures
  77173. * @param images array of glTF image interfaces
  77174. * @param textures array of glTF texture interfaces
  77175. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77176. * @param imageData map of image file name to data
  77177. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77178. * @returns glTF PBR Metallic Roughness factors
  77179. */
  77180. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77181. /**
  77182. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77183. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77184. * @param mimeType mime type to use for the textures
  77185. * @param images array of glTF image interfaces
  77186. * @param textures array of glTF texture interfaces
  77187. * @param materials array of glTF material interfaces
  77188. * @param imageData map of image file name to data
  77189. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77190. */
  77191. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77192. private setMetallicRoughnessPbrMaterial;
  77193. private getPixelsFromTexture;
  77194. /**
  77195. * Extracts a texture from a Babylon texture into file data and glTF data
  77196. * @param babylonTexture Babylon texture to extract
  77197. * @param mimeType Mime Type of the babylonTexture
  77198. * @return glTF texture info, or null if the texture format is not supported
  77199. */
  77200. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77201. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77202. /**
  77203. * Builds a texture from base64 string
  77204. * @param base64Texture base64 texture string
  77205. * @param baseTextureName Name to use for the texture
  77206. * @param mimeType image mime type for the texture
  77207. * @param images array of images
  77208. * @param textures array of textures
  77209. * @param imageData map of image data
  77210. * @returns glTF texture info, or null if the texture format is not supported
  77211. */
  77212. private _getTextureInfoFromBase64;
  77213. }
  77214. }
  77215. declare module BABYLON {
  77216. /**
  77217. * Class for holding and downloading glTF file data
  77218. */
  77219. export class GLTFData {
  77220. /**
  77221. * Object which contains the file name as the key and its data as the value
  77222. */
  77223. glTFFiles: {
  77224. [fileName: string]: string | Blob;
  77225. };
  77226. /**
  77227. * Initializes the glTF file object
  77228. */
  77229. constructor();
  77230. /**
  77231. * Downloads the glTF data as files based on their names and data
  77232. */
  77233. downloadFiles(): void;
  77234. }
  77235. }
  77236. declare module BABYLON {
  77237. /**
  77238. * Holds a collection of exporter options and parameters
  77239. */
  77240. export interface IExportOptions {
  77241. /**
  77242. * Function which indicates whether a babylon node should be exported or not
  77243. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77244. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77245. */
  77246. shouldExportNode?(node: Node): boolean;
  77247. /**
  77248. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77249. * @param metadata source metadata to read from
  77250. * @returns the data to store to glTF node extras
  77251. */
  77252. metadataSelector?(metadata: any): any;
  77253. /**
  77254. * The sample rate to bake animation curves
  77255. */
  77256. animationSampleRate?: number;
  77257. /**
  77258. * Begin serialization without waiting for the scene to be ready
  77259. */
  77260. exportWithoutWaitingForScene?: boolean;
  77261. /**
  77262. * Indicates if coordinate system swapping root nodes should be included in export
  77263. */
  77264. includeCoordinateSystemConversionNodes?: boolean;
  77265. }
  77266. /**
  77267. * Class for generating glTF data from a Babylon scene.
  77268. */
  77269. export class GLTF2Export {
  77270. /**
  77271. * Exports the geometry of the scene to .gltf file format asynchronously
  77272. * @param scene Babylon scene with scene hierarchy information
  77273. * @param filePrefix File prefix to use when generating the glTF file
  77274. * @param options Exporter options
  77275. * @returns Returns an object with a .gltf file and associates texture names
  77276. * as keys and their data and paths as values
  77277. */
  77278. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77279. private static _PreExportAsync;
  77280. private static _PostExportAsync;
  77281. /**
  77282. * Exports the geometry of the scene to .glb file format asychronously
  77283. * @param scene Babylon scene with scene hierarchy information
  77284. * @param filePrefix File prefix to use when generating glb file
  77285. * @param options Exporter options
  77286. * @returns Returns an object with a .glb filename as key and data as value
  77287. */
  77288. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77289. }
  77290. }
  77291. declare module BABYLON.GLTF2.Exporter {
  77292. /**
  77293. * @hidden
  77294. */
  77295. export class _GLTFUtilities {
  77296. /**
  77297. * Creates a buffer view based on the supplied arguments
  77298. * @param bufferIndex index value of the specified buffer
  77299. * @param byteOffset byte offset value
  77300. * @param byteLength byte length of the bufferView
  77301. * @param byteStride byte distance between conequential elements
  77302. * @param name name of the buffer view
  77303. * @returns bufferView for glTF
  77304. */
  77305. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77306. /**
  77307. * Creates an accessor based on the supplied arguments
  77308. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77309. * @param name The name of the accessor
  77310. * @param type The type of the accessor
  77311. * @param componentType The datatype of components in the attribute
  77312. * @param count The number of attributes referenced by this accessor
  77313. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77314. * @param min Minimum value of each component in this attribute
  77315. * @param max Maximum value of each component in this attribute
  77316. * @returns accessor for glTF
  77317. */
  77318. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77319. /**
  77320. * Calculates the minimum and maximum values of an array of position floats
  77321. * @param positions Positions array of a mesh
  77322. * @param vertexStart Starting vertex offset to calculate min and max values
  77323. * @param vertexCount Number of vertices to check for min and max values
  77324. * @returns min number array and max number array
  77325. */
  77326. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77327. min: number[];
  77328. max: number[];
  77329. };
  77330. /**
  77331. * Converts a new right-handed Vector3
  77332. * @param vector vector3 array
  77333. * @returns right-handed Vector3
  77334. */
  77335. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77336. /**
  77337. * Converts a Vector3 to right-handed
  77338. * @param vector Vector3 to convert to right-handed
  77339. */
  77340. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77341. /**
  77342. * Converts a three element number array to right-handed
  77343. * @param vector number array to convert to right-handed
  77344. */
  77345. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77346. /**
  77347. * Converts a new right-handed Vector3
  77348. * @param vector vector3 array
  77349. * @returns right-handed Vector3
  77350. */
  77351. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77352. /**
  77353. * Converts a Vector3 to right-handed
  77354. * @param vector Vector3 to convert to right-handed
  77355. */
  77356. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77357. /**
  77358. * Converts a three element number array to right-handed
  77359. * @param vector number array to convert to right-handed
  77360. */
  77361. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77362. /**
  77363. * Converts a Vector4 to right-handed
  77364. * @param vector Vector4 to convert to right-handed
  77365. */
  77366. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77367. /**
  77368. * Converts a Vector4 to right-handed
  77369. * @param vector Vector4 to convert to right-handed
  77370. */
  77371. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77372. /**
  77373. * Converts a Quaternion to right-handed
  77374. * @param quaternion Source quaternion to convert to right-handed
  77375. */
  77376. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77377. /**
  77378. * Converts a Quaternion to right-handed
  77379. * @param quaternion Source quaternion to convert to right-handed
  77380. */
  77381. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77382. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77383. }
  77384. }
  77385. declare module BABYLON.GLTF2.Exporter {
  77386. /**
  77387. * Converts Babylon Scene into glTF 2.0.
  77388. * @hidden
  77389. */
  77390. export class _Exporter {
  77391. /**
  77392. * Stores the glTF to export
  77393. */
  77394. _glTF: IGLTF;
  77395. /**
  77396. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77397. */
  77398. _bufferViews: IBufferView[];
  77399. /**
  77400. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77401. */
  77402. _accessors: IAccessor[];
  77403. /**
  77404. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77405. */
  77406. _nodes: INode[];
  77407. /**
  77408. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77409. */
  77410. private _scenes;
  77411. /**
  77412. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77413. */
  77414. private _meshes;
  77415. /**
  77416. * Stores all the generated material information, which represents the appearance of each primitive
  77417. */
  77418. _materials: IMaterial[];
  77419. _materialMap: {
  77420. [materialID: number]: number;
  77421. };
  77422. /**
  77423. * Stores all the generated texture information, which is referenced by glTF materials
  77424. */
  77425. _textures: ITexture[];
  77426. /**
  77427. * Stores all the generated image information, which is referenced by glTF textures
  77428. */
  77429. _images: IImage[];
  77430. /**
  77431. * Stores all the texture samplers
  77432. */
  77433. _samplers: ISampler[];
  77434. /**
  77435. * Stores all the generated animation samplers, which is referenced by glTF animations
  77436. */
  77437. /**
  77438. * Stores the animations for glTF models
  77439. */
  77440. private _animations;
  77441. /**
  77442. * Stores the total amount of bytes stored in the glTF buffer
  77443. */
  77444. private _totalByteLength;
  77445. /**
  77446. * Stores a reference to the Babylon scene containing the source geometry and material information
  77447. */
  77448. _babylonScene: Scene;
  77449. /**
  77450. * Stores a map of the image data, where the key is the file name and the value
  77451. * is the image data
  77452. */
  77453. _imageData: {
  77454. [fileName: string]: {
  77455. data: Uint8Array;
  77456. mimeType: ImageMimeType;
  77457. };
  77458. };
  77459. /**
  77460. * Stores a map of the unique id of a node to its index in the node array
  77461. */
  77462. _nodeMap: {
  77463. [key: number]: number;
  77464. };
  77465. /**
  77466. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77467. */
  77468. _convertToRightHandedSystem: boolean;
  77469. /**
  77470. * Specifies if a Babylon node should be converted to right-handed on export
  77471. */
  77472. _convertToRightHandedSystemMap: {
  77473. [nodeId: number]: boolean;
  77474. };
  77475. _includeCoordinateSystemConversionNodes: boolean;
  77476. /**
  77477. * Baked animation sample rate
  77478. */
  77479. private _animationSampleRate;
  77480. private _options;
  77481. private _localEngine;
  77482. _glTFMaterialExporter: _GLTFMaterialExporter;
  77483. private _extensions;
  77484. private static _ExtensionNames;
  77485. private static _ExtensionFactories;
  77486. private _applyExtension;
  77487. private _applyExtensions;
  77488. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77489. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77490. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77491. [key: number]: number;
  77492. }): Promise<Nullable<INode>>;
  77493. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77494. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77495. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77496. private _forEachExtensions;
  77497. private _extensionsOnExporting;
  77498. /**
  77499. * Load glTF serializer extensions
  77500. */
  77501. private _loadExtensions;
  77502. /**
  77503. * Creates a glTF Exporter instance, which can accept optional exporter options
  77504. * @param babylonScene Babylon scene object
  77505. * @param options Options to modify the behavior of the exporter
  77506. */
  77507. constructor(babylonScene: Scene, options?: IExportOptions);
  77508. dispose(): void;
  77509. /**
  77510. * Registers a glTF exporter extension
  77511. * @param name Name of the extension to export
  77512. * @param factory The factory function that creates the exporter extension
  77513. */
  77514. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77515. /**
  77516. * Un-registers an exporter extension
  77517. * @param name The name fo the exporter extension
  77518. * @returns A boolean indicating whether the extension has been un-registered
  77519. */
  77520. static UnregisterExtension(name: string): boolean;
  77521. /**
  77522. * Lazy load a local engine
  77523. */
  77524. _getLocalEngine(): Engine;
  77525. private reorderIndicesBasedOnPrimitiveMode;
  77526. /**
  77527. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77528. * clock-wise during export to glTF
  77529. * @param submesh BabylonJS submesh
  77530. * @param primitiveMode Primitive mode of the mesh
  77531. * @param sideOrientation the winding order of the submesh
  77532. * @param vertexBufferKind The type of vertex attribute
  77533. * @param meshAttributeArray The vertex attribute data
  77534. * @param byteOffset The offset to the binary data
  77535. * @param binaryWriter The binary data for the glTF file
  77536. * @param convertToRightHandedSystem Converts the values to right-handed
  77537. */
  77538. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77539. /**
  77540. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77541. * clock-wise during export to glTF
  77542. * @param submesh BabylonJS submesh
  77543. * @param primitiveMode Primitive mode of the mesh
  77544. * @param sideOrientation the winding order of the submesh
  77545. * @param vertexBufferKind The type of vertex attribute
  77546. * @param meshAttributeArray The vertex attribute data
  77547. * @param byteOffset The offset to the binary data
  77548. * @param binaryWriter The binary data for the glTF file
  77549. * @param convertToRightHandedSystem Converts the values to right-handed
  77550. */
  77551. private reorderTriangleFillMode;
  77552. /**
  77553. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77554. * clock-wise during export to glTF
  77555. * @param submesh BabylonJS submesh
  77556. * @param primitiveMode Primitive mode of the mesh
  77557. * @param sideOrientation the winding order of the submesh
  77558. * @param vertexBufferKind The type of vertex attribute
  77559. * @param meshAttributeArray The vertex attribute data
  77560. * @param byteOffset The offset to the binary data
  77561. * @param binaryWriter The binary data for the glTF file
  77562. * @param convertToRightHandedSystem Converts the values to right-handed
  77563. */
  77564. private reorderTriangleStripDrawMode;
  77565. /**
  77566. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77567. * clock-wise during export to glTF
  77568. * @param submesh BabylonJS submesh
  77569. * @param primitiveMode Primitive mode of the mesh
  77570. * @param sideOrientation the winding order of the submesh
  77571. * @param vertexBufferKind The type of vertex attribute
  77572. * @param meshAttributeArray The vertex attribute data
  77573. * @param byteOffset The offset to the binary data
  77574. * @param binaryWriter The binary data for the glTF file
  77575. * @param convertToRightHandedSystem Converts the values to right-handed
  77576. */
  77577. private reorderTriangleFanMode;
  77578. /**
  77579. * Writes the vertex attribute data to binary
  77580. * @param vertices The vertices to write to the binary writer
  77581. * @param byteOffset The offset into the binary writer to overwrite binary data
  77582. * @param vertexAttributeKind The vertex attribute type
  77583. * @param meshAttributeArray The vertex attribute data
  77584. * @param binaryWriter The writer containing the binary data
  77585. * @param convertToRightHandedSystem Converts the values to right-handed
  77586. */
  77587. private writeVertexAttributeData;
  77588. /**
  77589. * Writes mesh attribute data to a data buffer
  77590. * Returns the bytelength of the data
  77591. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77592. * @param meshAttributeArray Array containing the attribute data
  77593. * @param binaryWriter The buffer to write the binary data to
  77594. * @param indices Used to specify the order of the vertex data
  77595. * @param convertToRightHandedSystem Converts the values to right-handed
  77596. */
  77597. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77598. /**
  77599. * Generates glTF json data
  77600. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77601. * @param glTFPrefix Text to use when prefixing a glTF file
  77602. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77603. * @returns json data as string
  77604. */
  77605. private generateJSON;
  77606. /**
  77607. * Generates data for .gltf and .bin files based on the glTF prefix string
  77608. * @param glTFPrefix Text to use when prefixing a glTF file
  77609. * @param dispose Dispose the exporter
  77610. * @returns GLTFData with glTF file data
  77611. */
  77612. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77613. /**
  77614. * Creates a binary buffer for glTF
  77615. * @returns array buffer for binary data
  77616. */
  77617. private _generateBinaryAsync;
  77618. /**
  77619. * Pads the number to a multiple of 4
  77620. * @param num number to pad
  77621. * @returns padded number
  77622. */
  77623. private _getPadding;
  77624. /**
  77625. * @hidden
  77626. */
  77627. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77628. /**
  77629. * Sets the TRS for each node
  77630. * @param node glTF Node for storing the transformation data
  77631. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77632. * @param convertToRightHandedSystem Converts the values to right-handed
  77633. */
  77634. private setNodeTransformation;
  77635. private getVertexBufferFromMesh;
  77636. /**
  77637. * Creates a bufferview based on the vertices type for the Babylon mesh
  77638. * @param kind Indicates the type of vertices data
  77639. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77640. * @param binaryWriter The buffer to write the bufferview data to
  77641. * @param convertToRightHandedSystem Converts the values to right-handed
  77642. */
  77643. private createBufferViewKind;
  77644. /**
  77645. * The primitive mode of the Babylon mesh
  77646. * @param babylonMesh The BabylonJS mesh
  77647. */
  77648. private getMeshPrimitiveMode;
  77649. /**
  77650. * Sets the primitive mode of the glTF mesh primitive
  77651. * @param meshPrimitive glTF mesh primitive
  77652. * @param primitiveMode The primitive mode
  77653. */
  77654. private setPrimitiveMode;
  77655. /**
  77656. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77657. * @param meshPrimitive glTF mesh primitive
  77658. * @param attributeKind vertex attribute
  77659. * @returns boolean specifying if uv coordinates are present
  77660. */
  77661. private setAttributeKind;
  77662. /**
  77663. * Sets data for the primitive attributes of each submesh
  77664. * @param mesh glTF Mesh object to store the primitive attribute information
  77665. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77666. * @param binaryWriter Buffer to write the attribute data to
  77667. * @param convertToRightHandedSystem Converts the values to right-handed
  77668. */
  77669. private setPrimitiveAttributesAsync;
  77670. /**
  77671. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77672. * @param node The node to check
  77673. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77674. */
  77675. private isBabylonCoordinateSystemConvertingNode;
  77676. /**
  77677. * Creates a glTF scene based on the array of meshes
  77678. * Returns the the total byte offset
  77679. * @param babylonScene Babylon scene to get the mesh data from
  77680. * @param binaryWriter Buffer to write binary data to
  77681. */
  77682. private createSceneAsync;
  77683. /**
  77684. * Creates a mapping of Node unique id to node index and handles animations
  77685. * @param babylonScene Babylon Scene
  77686. * @param nodes Babylon transform nodes
  77687. * @param binaryWriter Buffer to write binary data to
  77688. * @returns Node mapping of unique id to index
  77689. */
  77690. private createNodeMapAndAnimationsAsync;
  77691. /**
  77692. * Creates a glTF node from a Babylon mesh
  77693. * @param babylonMesh Source Babylon mesh
  77694. * @param binaryWriter Buffer for storing geometry data
  77695. * @param convertToRightHandedSystem Converts the values to right-handed
  77696. * @param nodeMap Node mapping of unique id to glTF node index
  77697. * @returns glTF node
  77698. */
  77699. private createNodeAsync;
  77700. }
  77701. /**
  77702. * @hidden
  77703. *
  77704. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77705. */
  77706. export class _BinaryWriter {
  77707. /**
  77708. * Array buffer which stores all binary data
  77709. */
  77710. private _arrayBuffer;
  77711. /**
  77712. * View of the array buffer
  77713. */
  77714. private _dataView;
  77715. /**
  77716. * byte offset of data in array buffer
  77717. */
  77718. private _byteOffset;
  77719. /**
  77720. * Initialize binary writer with an initial byte length
  77721. * @param byteLength Initial byte length of the array buffer
  77722. */
  77723. constructor(byteLength: number);
  77724. /**
  77725. * Resize the array buffer to the specified byte length
  77726. * @param byteLength
  77727. */
  77728. private resizeBuffer;
  77729. /**
  77730. * Get an array buffer with the length of the byte offset
  77731. * @returns ArrayBuffer resized to the byte offset
  77732. */
  77733. getArrayBuffer(): ArrayBuffer;
  77734. /**
  77735. * Get the byte offset of the array buffer
  77736. * @returns byte offset
  77737. */
  77738. getByteOffset(): number;
  77739. /**
  77740. * Stores an UInt8 in the array buffer
  77741. * @param entry
  77742. * @param byteOffset If defined, specifies where to set the value as an offset.
  77743. */
  77744. setUInt8(entry: number, byteOffset?: number): void;
  77745. /**
  77746. * Gets an UInt32 in the array buffer
  77747. * @param entry
  77748. * @param byteOffset If defined, specifies where to set the value as an offset.
  77749. */
  77750. getUInt32(byteOffset: number): number;
  77751. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77752. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77753. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77754. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77755. /**
  77756. * Stores a Float32 in the array buffer
  77757. * @param entry
  77758. */
  77759. setFloat32(entry: number, byteOffset?: number): void;
  77760. /**
  77761. * Stores an UInt32 in the array buffer
  77762. * @param entry
  77763. * @param byteOffset If defined, specifies where to set the value as an offset.
  77764. */
  77765. setUInt32(entry: number, byteOffset?: number): void;
  77766. }
  77767. }
  77768. declare module BABYLON.GLTF2.Exporter {
  77769. /**
  77770. * @hidden
  77771. * Interface to store animation data.
  77772. */
  77773. export interface _IAnimationData {
  77774. /**
  77775. * Keyframe data.
  77776. */
  77777. inputs: number[];
  77778. /**
  77779. * Value data.
  77780. */
  77781. outputs: number[][];
  77782. /**
  77783. * Animation interpolation data.
  77784. */
  77785. samplerInterpolation: AnimationSamplerInterpolation;
  77786. /**
  77787. * Minimum keyframe value.
  77788. */
  77789. inputsMin: number;
  77790. /**
  77791. * Maximum keyframe value.
  77792. */
  77793. inputsMax: number;
  77794. }
  77795. /**
  77796. * @hidden
  77797. */
  77798. export interface _IAnimationInfo {
  77799. /**
  77800. * The target channel for the animation
  77801. */
  77802. animationChannelTargetPath: AnimationChannelTargetPath;
  77803. /**
  77804. * The glTF accessor type for the data.
  77805. */
  77806. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77807. /**
  77808. * Specifies if quaternions should be used.
  77809. */
  77810. useQuaternion: boolean;
  77811. }
  77812. /**
  77813. * @hidden
  77814. * Utility class for generating glTF animation data from BabylonJS.
  77815. */
  77816. export class _GLTFAnimation {
  77817. /**
  77818. * @ignore
  77819. *
  77820. * Creates glTF channel animation from BabylonJS animation.
  77821. * @param babylonTransformNode - BabylonJS mesh.
  77822. * @param animation - animation.
  77823. * @param animationChannelTargetPath - The target animation channel.
  77824. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77825. * @param useQuaternion - Specifies if quaternions are used.
  77826. * @returns nullable IAnimationData
  77827. */
  77828. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77829. private static _DeduceAnimationInfo;
  77830. /**
  77831. * @ignore
  77832. * Create node animations from the transform node animations
  77833. * @param babylonNode
  77834. * @param runtimeGLTFAnimation
  77835. * @param idleGLTFAnimations
  77836. * @param nodeMap
  77837. * @param nodes
  77838. * @param binaryWriter
  77839. * @param bufferViews
  77840. * @param accessors
  77841. * @param convertToRightHandedSystem
  77842. * @param animationSampleRate
  77843. */
  77844. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77845. [key: number]: number;
  77846. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77847. /**
  77848. * @ignore
  77849. * Create node animations from the animation groups
  77850. * @param babylonScene
  77851. * @param glTFAnimations
  77852. * @param nodeMap
  77853. * @param nodes
  77854. * @param binaryWriter
  77855. * @param bufferViews
  77856. * @param accessors
  77857. * @param convertToRightHandedSystemMap
  77858. * @param animationSampleRate
  77859. */
  77860. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77861. [key: number]: number;
  77862. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77863. [nodeId: number]: boolean;
  77864. }, animationSampleRate: number): void;
  77865. private static AddAnimation;
  77866. /**
  77867. * Create a baked animation
  77868. * @param babylonTransformNode BabylonJS mesh
  77869. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77870. * @param animationChannelTargetPath animation target channel
  77871. * @param minFrame minimum animation frame
  77872. * @param maxFrame maximum animation frame
  77873. * @param fps frames per second of the animation
  77874. * @param inputs input key frames of the animation
  77875. * @param outputs output key frame data of the animation
  77876. * @param convertToRightHandedSystem converts the values to right-handed
  77877. * @param useQuaternion specifies if quaternions should be used
  77878. */
  77879. private static _CreateBakedAnimation;
  77880. private static _ConvertFactorToVector3OrQuaternion;
  77881. private static _SetInterpolatedValue;
  77882. /**
  77883. * Creates linear animation from the animation key frames
  77884. * @param babylonTransformNode BabylonJS mesh
  77885. * @param animation BabylonJS animation
  77886. * @param animationChannelTargetPath The target animation channel
  77887. * @param frameDelta The difference between the last and first frame of the animation
  77888. * @param inputs Array to store the key frame times
  77889. * @param outputs Array to store the key frame data
  77890. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77891. * @param useQuaternion Specifies if quaternions are used in the animation
  77892. */
  77893. private static _CreateLinearOrStepAnimation;
  77894. /**
  77895. * Creates cubic spline animation from the animation key frames
  77896. * @param babylonTransformNode BabylonJS mesh
  77897. * @param animation BabylonJS animation
  77898. * @param animationChannelTargetPath The target animation channel
  77899. * @param frameDelta The difference between the last and first frame of the animation
  77900. * @param inputs Array to store the key frame times
  77901. * @param outputs Array to store the key frame data
  77902. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77903. * @param useQuaternion Specifies if quaternions are used in the animation
  77904. */
  77905. private static _CreateCubicSplineAnimation;
  77906. private static _GetBasePositionRotationOrScale;
  77907. /**
  77908. * Adds a key frame value
  77909. * @param keyFrame
  77910. * @param animation
  77911. * @param outputs
  77912. * @param animationChannelTargetPath
  77913. * @param basePositionRotationOrScale
  77914. * @param convertToRightHandedSystem
  77915. * @param useQuaternion
  77916. */
  77917. private static _AddKeyframeValue;
  77918. /**
  77919. * Determine the interpolation based on the key frames
  77920. * @param keyFrames
  77921. * @param animationChannelTargetPath
  77922. * @param useQuaternion
  77923. */
  77924. private static _DeduceInterpolation;
  77925. /**
  77926. * Adds an input tangent or output tangent to the output data
  77927. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77928. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77929. * @param outputs The animation data by keyframe
  77930. * @param animationChannelTargetPath The target animation channel
  77931. * @param interpolation The interpolation type
  77932. * @param keyFrame The key frame with the animation data
  77933. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77934. * @param useQuaternion Specifies if quaternions are used
  77935. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77936. */
  77937. private static AddSplineTangent;
  77938. /**
  77939. * Get the minimum and maximum key frames' frame values
  77940. * @param keyFrames animation key frames
  77941. * @returns the minimum and maximum key frame value
  77942. */
  77943. private static calculateMinMaxKeyFrames;
  77944. }
  77945. }
  77946. declare module BABYLON.GLTF2.Exporter {
  77947. /** @hidden */
  77948. export var textureTransformPixelShader: {
  77949. name: string;
  77950. shader: string;
  77951. };
  77952. }
  77953. declare module BABYLON.GLTF2.Exporter.Extensions {
  77954. /**
  77955. * @hidden
  77956. */
  77957. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77958. private _recordedTextures;
  77959. /** Name of this extension */
  77960. readonly name: string;
  77961. /** Defines whether this extension is enabled */
  77962. enabled: boolean;
  77963. /** Defines whether this extension is required */
  77964. required: boolean;
  77965. /** Reference to the glTF exporter */
  77966. private _wasUsed;
  77967. constructor(exporter: _Exporter);
  77968. dispose(): void;
  77969. /** @hidden */
  77970. get wasUsed(): boolean;
  77971. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77972. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77973. /**
  77974. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77975. * @param babylonTexture
  77976. * @param offset
  77977. * @param rotation
  77978. * @param scale
  77979. * @param scene
  77980. */
  77981. private _textureTransformTextureAsync;
  77982. }
  77983. }
  77984. declare module BABYLON.GLTF2.Exporter.Extensions {
  77985. /**
  77986. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77987. */
  77988. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77989. /** The name of this extension. */
  77990. readonly name: string;
  77991. /** Defines whether this extension is enabled. */
  77992. enabled: boolean;
  77993. /** Defines whether this extension is required */
  77994. required: boolean;
  77995. /** Reference to the glTF exporter */
  77996. private _exporter;
  77997. private _lights;
  77998. /** @hidden */
  77999. constructor(exporter: _Exporter);
  78000. /** @hidden */
  78001. dispose(): void;
  78002. /** @hidden */
  78003. get wasUsed(): boolean;
  78004. /** @hidden */
  78005. onExporting(): void;
  78006. /**
  78007. * Define this method to modify the default behavior when exporting a node
  78008. * @param context The context when exporting the node
  78009. * @param node glTF node
  78010. * @param babylonNode BabylonJS node
  78011. * @param nodeMap Node mapping of unique id to glTF node index
  78012. * @returns nullable INode promise
  78013. */
  78014. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78015. [key: number]: number;
  78016. }): Promise<Nullable<INode>>;
  78017. }
  78018. }
  78019. declare module BABYLON.GLTF2.Exporter.Extensions {
  78020. /**
  78021. * @hidden
  78022. */
  78023. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78024. /** Name of this extension */
  78025. readonly name: string;
  78026. /** Defines whether this extension is enabled */
  78027. enabled: boolean;
  78028. /** Defines whether this extension is required */
  78029. required: boolean;
  78030. /** Reference to the glTF exporter */
  78031. private _textureInfos;
  78032. private _exportedTextures;
  78033. private _wasUsed;
  78034. constructor(exporter: _Exporter);
  78035. dispose(): void;
  78036. /** @hidden */
  78037. get wasUsed(): boolean;
  78038. private _getTextureIndex;
  78039. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78040. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78041. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78042. }
  78043. }
  78044. declare module BABYLON {
  78045. /**
  78046. * Class for generating STL data from a Babylon scene.
  78047. */
  78048. export class STLExport {
  78049. /**
  78050. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78051. * @param meshes list defines the mesh to serialize
  78052. * @param download triggers the automatic download of the file.
  78053. * @param fileName changes the downloads fileName.
  78054. * @param binary changes the STL to a binary type.
  78055. * @param isLittleEndian toggle for binary type exporter.
  78056. * @returns the STL as UTF8 string
  78057. */
  78058. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78059. }
  78060. }
  78061. declare module "babylonjs-gltf2interface" {
  78062. export = BABYLON.GLTF2;
  78063. }
  78064. /**
  78065. * Module for glTF 2.0 Interface
  78066. */
  78067. declare module BABYLON.GLTF2 {
  78068. /**
  78069. * The datatype of the components in the attribute
  78070. */
  78071. const enum AccessorComponentType {
  78072. /**
  78073. * Byte
  78074. */
  78075. BYTE = 5120,
  78076. /**
  78077. * Unsigned Byte
  78078. */
  78079. UNSIGNED_BYTE = 5121,
  78080. /**
  78081. * Short
  78082. */
  78083. SHORT = 5122,
  78084. /**
  78085. * Unsigned Short
  78086. */
  78087. UNSIGNED_SHORT = 5123,
  78088. /**
  78089. * Unsigned Int
  78090. */
  78091. UNSIGNED_INT = 5125,
  78092. /**
  78093. * Float
  78094. */
  78095. FLOAT = 5126,
  78096. }
  78097. /**
  78098. * Specifies if the attirbute is a scalar, vector, or matrix
  78099. */
  78100. const enum AccessorType {
  78101. /**
  78102. * Scalar
  78103. */
  78104. SCALAR = "SCALAR",
  78105. /**
  78106. * Vector2
  78107. */
  78108. VEC2 = "VEC2",
  78109. /**
  78110. * Vector3
  78111. */
  78112. VEC3 = "VEC3",
  78113. /**
  78114. * Vector4
  78115. */
  78116. VEC4 = "VEC4",
  78117. /**
  78118. * Matrix2x2
  78119. */
  78120. MAT2 = "MAT2",
  78121. /**
  78122. * Matrix3x3
  78123. */
  78124. MAT3 = "MAT3",
  78125. /**
  78126. * Matrix4x4
  78127. */
  78128. MAT4 = "MAT4",
  78129. }
  78130. /**
  78131. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78132. */
  78133. const enum AnimationChannelTargetPath {
  78134. /**
  78135. * Translation
  78136. */
  78137. TRANSLATION = "translation",
  78138. /**
  78139. * Rotation
  78140. */
  78141. ROTATION = "rotation",
  78142. /**
  78143. * Scale
  78144. */
  78145. SCALE = "scale",
  78146. /**
  78147. * Weights
  78148. */
  78149. WEIGHTS = "weights",
  78150. }
  78151. /**
  78152. * Interpolation algorithm
  78153. */
  78154. const enum AnimationSamplerInterpolation {
  78155. /**
  78156. * The animated values are linearly interpolated between keyframes
  78157. */
  78158. LINEAR = "LINEAR",
  78159. /**
  78160. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78161. */
  78162. STEP = "STEP",
  78163. /**
  78164. * The animation's interpolation is computed using a cubic spline with specified tangents
  78165. */
  78166. CUBICSPLINE = "CUBICSPLINE",
  78167. }
  78168. /**
  78169. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78170. */
  78171. const enum CameraType {
  78172. /**
  78173. * A perspective camera containing properties to create a perspective projection matrix
  78174. */
  78175. PERSPECTIVE = "perspective",
  78176. /**
  78177. * An orthographic camera containing properties to create an orthographic projection matrix
  78178. */
  78179. ORTHOGRAPHIC = "orthographic",
  78180. }
  78181. /**
  78182. * The mime-type of the image
  78183. */
  78184. const enum ImageMimeType {
  78185. /**
  78186. * JPEG Mime-type
  78187. */
  78188. JPEG = "image/jpeg",
  78189. /**
  78190. * PNG Mime-type
  78191. */
  78192. PNG = "image/png",
  78193. }
  78194. /**
  78195. * The alpha rendering mode of the material
  78196. */
  78197. const enum MaterialAlphaMode {
  78198. /**
  78199. * The alpha value is ignored and the rendered output is fully opaque
  78200. */
  78201. OPAQUE = "OPAQUE",
  78202. /**
  78203. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78204. */
  78205. MASK = "MASK",
  78206. /**
  78207. * 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)
  78208. */
  78209. BLEND = "BLEND",
  78210. }
  78211. /**
  78212. * The type of the primitives to render
  78213. */
  78214. const enum MeshPrimitiveMode {
  78215. /**
  78216. * Points
  78217. */
  78218. POINTS = 0,
  78219. /**
  78220. * Lines
  78221. */
  78222. LINES = 1,
  78223. /**
  78224. * Line Loop
  78225. */
  78226. LINE_LOOP = 2,
  78227. /**
  78228. * Line Strip
  78229. */
  78230. LINE_STRIP = 3,
  78231. /**
  78232. * Triangles
  78233. */
  78234. TRIANGLES = 4,
  78235. /**
  78236. * Triangle Strip
  78237. */
  78238. TRIANGLE_STRIP = 5,
  78239. /**
  78240. * Triangle Fan
  78241. */
  78242. TRIANGLE_FAN = 6,
  78243. }
  78244. /**
  78245. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78246. */
  78247. const enum TextureMagFilter {
  78248. /**
  78249. * Nearest
  78250. */
  78251. NEAREST = 9728,
  78252. /**
  78253. * Linear
  78254. */
  78255. LINEAR = 9729,
  78256. }
  78257. /**
  78258. * Minification filter. All valid values correspond to WebGL enums
  78259. */
  78260. const enum TextureMinFilter {
  78261. /**
  78262. * Nearest
  78263. */
  78264. NEAREST = 9728,
  78265. /**
  78266. * Linear
  78267. */
  78268. LINEAR = 9729,
  78269. /**
  78270. * Nearest Mip-Map Nearest
  78271. */
  78272. NEAREST_MIPMAP_NEAREST = 9984,
  78273. /**
  78274. * Linear Mipmap Nearest
  78275. */
  78276. LINEAR_MIPMAP_NEAREST = 9985,
  78277. /**
  78278. * Nearest Mipmap Linear
  78279. */
  78280. NEAREST_MIPMAP_LINEAR = 9986,
  78281. /**
  78282. * Linear Mipmap Linear
  78283. */
  78284. LINEAR_MIPMAP_LINEAR = 9987,
  78285. }
  78286. /**
  78287. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78288. */
  78289. const enum TextureWrapMode {
  78290. /**
  78291. * Clamp to Edge
  78292. */
  78293. CLAMP_TO_EDGE = 33071,
  78294. /**
  78295. * Mirrored Repeat
  78296. */
  78297. MIRRORED_REPEAT = 33648,
  78298. /**
  78299. * Repeat
  78300. */
  78301. REPEAT = 10497,
  78302. }
  78303. /**
  78304. * glTF Property
  78305. */
  78306. interface IProperty {
  78307. /**
  78308. * Dictionary object with extension-specific objects
  78309. */
  78310. extensions?: {
  78311. [key: string]: any;
  78312. };
  78313. /**
  78314. * Application-Specific data
  78315. */
  78316. extras?: any;
  78317. }
  78318. /**
  78319. * glTF Child of Root Property
  78320. */
  78321. interface IChildRootProperty extends IProperty {
  78322. /**
  78323. * The user-defined name of this object
  78324. */
  78325. name?: string;
  78326. }
  78327. /**
  78328. * Indices of those attributes that deviate from their initialization value
  78329. */
  78330. interface IAccessorSparseIndices extends IProperty {
  78331. /**
  78332. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78333. */
  78334. bufferView: number;
  78335. /**
  78336. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78337. */
  78338. byteOffset?: number;
  78339. /**
  78340. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78341. */
  78342. componentType: AccessorComponentType;
  78343. }
  78344. /**
  78345. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78346. */
  78347. interface IAccessorSparseValues extends IProperty {
  78348. /**
  78349. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78350. */
  78351. bufferView: number;
  78352. /**
  78353. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78354. */
  78355. byteOffset?: number;
  78356. }
  78357. /**
  78358. * Sparse storage of attributes that deviate from their initialization value
  78359. */
  78360. interface IAccessorSparse extends IProperty {
  78361. /**
  78362. * The number of attributes encoded in this sparse accessor
  78363. */
  78364. count: number;
  78365. /**
  78366. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78367. */
  78368. indices: IAccessorSparseIndices;
  78369. /**
  78370. * 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
  78371. */
  78372. values: IAccessorSparseValues;
  78373. }
  78374. /**
  78375. * 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
  78376. */
  78377. interface IAccessor extends IChildRootProperty {
  78378. /**
  78379. * The index of the bufferview
  78380. */
  78381. bufferView?: number;
  78382. /**
  78383. * The offset relative to the start of the bufferView in bytes
  78384. */
  78385. byteOffset?: number;
  78386. /**
  78387. * The datatype of components in the attribute
  78388. */
  78389. componentType: AccessorComponentType;
  78390. /**
  78391. * Specifies whether integer data values should be normalized
  78392. */
  78393. normalized?: boolean;
  78394. /**
  78395. * The number of attributes referenced by this accessor
  78396. */
  78397. count: number;
  78398. /**
  78399. * Specifies if the attribute is a scalar, vector, or matrix
  78400. */
  78401. type: AccessorType;
  78402. /**
  78403. * Maximum value of each component in this attribute
  78404. */
  78405. max?: number[];
  78406. /**
  78407. * Minimum value of each component in this attribute
  78408. */
  78409. min?: number[];
  78410. /**
  78411. * Sparse storage of attributes that deviate from their initialization value
  78412. */
  78413. sparse?: IAccessorSparse;
  78414. }
  78415. /**
  78416. * Targets an animation's sampler at a node's property
  78417. */
  78418. interface IAnimationChannel extends IProperty {
  78419. /**
  78420. * The index of a sampler in this animation used to compute the value for the target
  78421. */
  78422. sampler: number;
  78423. /**
  78424. * The index of the node and TRS property to target
  78425. */
  78426. target: IAnimationChannelTarget;
  78427. }
  78428. /**
  78429. * The index of the node and TRS property that an animation channel targets
  78430. */
  78431. interface IAnimationChannelTarget extends IProperty {
  78432. /**
  78433. * The index of the node to target
  78434. */
  78435. node: number;
  78436. /**
  78437. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78438. */
  78439. path: AnimationChannelTargetPath;
  78440. }
  78441. /**
  78442. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78443. */
  78444. interface IAnimationSampler extends IProperty {
  78445. /**
  78446. * The index of an accessor containing keyframe input values, e.g., time
  78447. */
  78448. input: number;
  78449. /**
  78450. * Interpolation algorithm
  78451. */
  78452. interpolation?: AnimationSamplerInterpolation;
  78453. /**
  78454. * The index of an accessor, containing keyframe output values
  78455. */
  78456. output: number;
  78457. }
  78458. /**
  78459. * A keyframe animation
  78460. */
  78461. interface IAnimation extends IChildRootProperty {
  78462. /**
  78463. * An array of channels, each of which targets an animation's sampler at a node's property
  78464. */
  78465. channels: IAnimationChannel[];
  78466. /**
  78467. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78468. */
  78469. samplers: IAnimationSampler[];
  78470. }
  78471. /**
  78472. * Metadata about the glTF asset
  78473. */
  78474. interface IAsset extends IChildRootProperty {
  78475. /**
  78476. * A copyright message suitable for display to credit the content creator
  78477. */
  78478. copyright?: string;
  78479. /**
  78480. * Tool that generated this glTF model. Useful for debugging
  78481. */
  78482. generator?: string;
  78483. /**
  78484. * The glTF version that this asset targets
  78485. */
  78486. version: string;
  78487. /**
  78488. * The minimum glTF version that this asset targets
  78489. */
  78490. minVersion?: string;
  78491. }
  78492. /**
  78493. * A buffer points to binary geometry, animation, or skins
  78494. */
  78495. interface IBuffer extends IChildRootProperty {
  78496. /**
  78497. * 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
  78498. */
  78499. uri?: string;
  78500. /**
  78501. * The length of the buffer in bytes
  78502. */
  78503. byteLength: number;
  78504. }
  78505. /**
  78506. * A view into a buffer generally representing a subset of the buffer
  78507. */
  78508. interface IBufferView extends IChildRootProperty {
  78509. /**
  78510. * The index of the buffer
  78511. */
  78512. buffer: number;
  78513. /**
  78514. * The offset into the buffer in bytes
  78515. */
  78516. byteOffset?: number;
  78517. /**
  78518. * The lenth of the bufferView in bytes
  78519. */
  78520. byteLength: number;
  78521. /**
  78522. * The stride, in bytes
  78523. */
  78524. byteStride?: number;
  78525. }
  78526. /**
  78527. * An orthographic camera containing properties to create an orthographic projection matrix
  78528. */
  78529. interface ICameraOrthographic extends IProperty {
  78530. /**
  78531. * The floating-point horizontal magnification of the view. Must not be zero
  78532. */
  78533. xmag: number;
  78534. /**
  78535. * The floating-point vertical magnification of the view. Must not be zero
  78536. */
  78537. ymag: number;
  78538. /**
  78539. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78540. */
  78541. zfar: number;
  78542. /**
  78543. * The floating-point distance to the near clipping plane
  78544. */
  78545. znear: number;
  78546. }
  78547. /**
  78548. * A perspective camera containing properties to create a perspective projection matrix
  78549. */
  78550. interface ICameraPerspective extends IProperty {
  78551. /**
  78552. * The floating-point aspect ratio of the field of view
  78553. */
  78554. aspectRatio?: number;
  78555. /**
  78556. * The floating-point vertical field of view in radians
  78557. */
  78558. yfov: number;
  78559. /**
  78560. * The floating-point distance to the far clipping plane
  78561. */
  78562. zfar?: number;
  78563. /**
  78564. * The floating-point distance to the near clipping plane
  78565. */
  78566. znear: number;
  78567. }
  78568. /**
  78569. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78570. */
  78571. interface ICamera extends IChildRootProperty {
  78572. /**
  78573. * An orthographic camera containing properties to create an orthographic projection matrix
  78574. */
  78575. orthographic?: ICameraOrthographic;
  78576. /**
  78577. * A perspective camera containing properties to create a perspective projection matrix
  78578. */
  78579. perspective?: ICameraPerspective;
  78580. /**
  78581. * Specifies if the camera uses a perspective or orthographic projection
  78582. */
  78583. type: CameraType;
  78584. }
  78585. /**
  78586. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78587. */
  78588. interface IImage extends IChildRootProperty {
  78589. /**
  78590. * 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
  78591. */
  78592. uri?: string;
  78593. /**
  78594. * The image's MIME type
  78595. */
  78596. mimeType?: ImageMimeType;
  78597. /**
  78598. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78599. */
  78600. bufferView?: number;
  78601. }
  78602. /**
  78603. * Material Normal Texture Info
  78604. */
  78605. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78606. /**
  78607. * The scalar multiplier applied to each normal vector of the normal texture
  78608. */
  78609. scale?: number;
  78610. }
  78611. /**
  78612. * Material Occlusion Texture Info
  78613. */
  78614. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78615. /**
  78616. * A scalar multiplier controlling the amount of occlusion applied
  78617. */
  78618. strength?: number;
  78619. }
  78620. /**
  78621. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78622. */
  78623. interface IMaterialPbrMetallicRoughness {
  78624. /**
  78625. * The material's base color factor
  78626. */
  78627. baseColorFactor?: number[];
  78628. /**
  78629. * The base color texture
  78630. */
  78631. baseColorTexture?: ITextureInfo;
  78632. /**
  78633. * The metalness of the material
  78634. */
  78635. metallicFactor?: number;
  78636. /**
  78637. * The roughness of the material
  78638. */
  78639. roughnessFactor?: number;
  78640. /**
  78641. * The metallic-roughness texture
  78642. */
  78643. metallicRoughnessTexture?: ITextureInfo;
  78644. }
  78645. /**
  78646. * The material appearance of a primitive
  78647. */
  78648. interface IMaterial extends IChildRootProperty {
  78649. /**
  78650. * 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
  78651. */
  78652. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78653. /**
  78654. * The normal map texture
  78655. */
  78656. normalTexture?: IMaterialNormalTextureInfo;
  78657. /**
  78658. * The occlusion map texture
  78659. */
  78660. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78661. /**
  78662. * The emissive map texture
  78663. */
  78664. emissiveTexture?: ITextureInfo;
  78665. /**
  78666. * 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
  78667. */
  78668. emissiveFactor?: number[];
  78669. /**
  78670. * The alpha rendering mode of the material
  78671. */
  78672. alphaMode?: MaterialAlphaMode;
  78673. /**
  78674. * The alpha cutoff value of the material
  78675. */
  78676. alphaCutoff?: number;
  78677. /**
  78678. * Specifies whether the material is double sided
  78679. */
  78680. doubleSided?: boolean;
  78681. }
  78682. /**
  78683. * Geometry to be rendered with the given material
  78684. */
  78685. interface IMeshPrimitive extends IProperty {
  78686. /**
  78687. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78688. */
  78689. attributes: {
  78690. [name: string]: number;
  78691. };
  78692. /**
  78693. * The index of the accessor that contains the indices
  78694. */
  78695. indices?: number;
  78696. /**
  78697. * The index of the material to apply to this primitive when rendering
  78698. */
  78699. material?: number;
  78700. /**
  78701. * The type of primitives to render. All valid values correspond to WebGL enums
  78702. */
  78703. mode?: MeshPrimitiveMode;
  78704. /**
  78705. * 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
  78706. */
  78707. targets?: {
  78708. [name: string]: number;
  78709. }[];
  78710. }
  78711. /**
  78712. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78713. */
  78714. interface IMesh extends IChildRootProperty {
  78715. /**
  78716. * An array of primitives, each defining geometry to be rendered with a material
  78717. */
  78718. primitives: IMeshPrimitive[];
  78719. /**
  78720. * Array of weights to be applied to the Morph Targets
  78721. */
  78722. weights?: number[];
  78723. }
  78724. /**
  78725. * A node in the node hierarchy
  78726. */
  78727. interface INode extends IChildRootProperty {
  78728. /**
  78729. * The index of the camera referenced by this node
  78730. */
  78731. camera?: number;
  78732. /**
  78733. * The indices of this node's children
  78734. */
  78735. children?: number[];
  78736. /**
  78737. * The index of the skin referenced by this node
  78738. */
  78739. skin?: number;
  78740. /**
  78741. * A floating-point 4x4 transformation matrix stored in column-major order
  78742. */
  78743. matrix?: number[];
  78744. /**
  78745. * The index of the mesh in this node
  78746. */
  78747. mesh?: number;
  78748. /**
  78749. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78750. */
  78751. rotation?: number[];
  78752. /**
  78753. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78754. */
  78755. scale?: number[];
  78756. /**
  78757. * The node's translation along the x, y, and z axes
  78758. */
  78759. translation?: number[];
  78760. /**
  78761. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78762. */
  78763. weights?: number[];
  78764. }
  78765. /**
  78766. * Texture sampler properties for filtering and wrapping modes
  78767. */
  78768. interface ISampler extends IChildRootProperty {
  78769. /**
  78770. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78771. */
  78772. magFilter?: TextureMagFilter;
  78773. /**
  78774. * Minification filter. All valid values correspond to WebGL enums
  78775. */
  78776. minFilter?: TextureMinFilter;
  78777. /**
  78778. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78779. */
  78780. wrapS?: TextureWrapMode;
  78781. /**
  78782. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78783. */
  78784. wrapT?: TextureWrapMode;
  78785. }
  78786. /**
  78787. * The root nodes of a scene
  78788. */
  78789. interface IScene extends IChildRootProperty {
  78790. /**
  78791. * The indices of each root node
  78792. */
  78793. nodes: number[];
  78794. }
  78795. /**
  78796. * Joints and matrices defining a skin
  78797. */
  78798. interface ISkin extends IChildRootProperty {
  78799. /**
  78800. * 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
  78801. */
  78802. inverseBindMatrices?: number;
  78803. /**
  78804. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78805. */
  78806. skeleton?: number;
  78807. /**
  78808. * 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)
  78809. */
  78810. joints: number[];
  78811. }
  78812. /**
  78813. * A texture and its sampler
  78814. */
  78815. interface ITexture extends IChildRootProperty {
  78816. /**
  78817. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78818. */
  78819. sampler?: number;
  78820. /**
  78821. * The index of the image used by this texture
  78822. */
  78823. source: number;
  78824. }
  78825. /**
  78826. * Reference to a texture
  78827. */
  78828. interface ITextureInfo extends IProperty {
  78829. /**
  78830. * The index of the texture
  78831. */
  78832. index: number;
  78833. /**
  78834. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78835. */
  78836. texCoord?: number;
  78837. }
  78838. /**
  78839. * The root object for a glTF asset
  78840. */
  78841. interface IGLTF extends IProperty {
  78842. /**
  78843. * An array of accessors. An accessor is a typed view into a bufferView
  78844. */
  78845. accessors?: IAccessor[];
  78846. /**
  78847. * An array of keyframe animations
  78848. */
  78849. animations?: IAnimation[];
  78850. /**
  78851. * Metadata about the glTF asset
  78852. */
  78853. asset: IAsset;
  78854. /**
  78855. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78856. */
  78857. buffers?: IBuffer[];
  78858. /**
  78859. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78860. */
  78861. bufferViews?: IBufferView[];
  78862. /**
  78863. * An array of cameras
  78864. */
  78865. cameras?: ICamera[];
  78866. /**
  78867. * Names of glTF extensions used somewhere in this asset
  78868. */
  78869. extensionsUsed?: string[];
  78870. /**
  78871. * Names of glTF extensions required to properly load this asset
  78872. */
  78873. extensionsRequired?: string[];
  78874. /**
  78875. * An array of images. An image defines data used to create a texture
  78876. */
  78877. images?: IImage[];
  78878. /**
  78879. * An array of materials. A material defines the appearance of a primitive
  78880. */
  78881. materials?: IMaterial[];
  78882. /**
  78883. * An array of meshes. A mesh is a set of primitives to be rendered
  78884. */
  78885. meshes?: IMesh[];
  78886. /**
  78887. * An array of nodes
  78888. */
  78889. nodes?: INode[];
  78890. /**
  78891. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78892. */
  78893. samplers?: ISampler[];
  78894. /**
  78895. * The index of the default scene
  78896. */
  78897. scene?: number;
  78898. /**
  78899. * An array of scenes
  78900. */
  78901. scenes?: IScene[];
  78902. /**
  78903. * An array of skins. A skin is defined by joints and matrices
  78904. */
  78905. skins?: ISkin[];
  78906. /**
  78907. * An array of textures
  78908. */
  78909. textures?: ITexture[];
  78910. }
  78911. /**
  78912. * The glTF validation results
  78913. * @ignore
  78914. */
  78915. interface IGLTFValidationResults {
  78916. info: {
  78917. generator: string;
  78918. hasAnimations: boolean;
  78919. hasDefaultScene: boolean;
  78920. hasMaterials: boolean;
  78921. hasMorphTargets: boolean;
  78922. hasSkins: boolean;
  78923. hasTextures: boolean;
  78924. maxAttributesUsed: number;
  78925. primitivesCount: number
  78926. };
  78927. issues: {
  78928. messages: Array<string>;
  78929. numErrors: number;
  78930. numHints: number;
  78931. numInfos: number;
  78932. numWarnings: number;
  78933. truncated: boolean
  78934. };
  78935. mimeType: string;
  78936. uri: string;
  78937. validatedAt: string;
  78938. validatorVersion: string;
  78939. }
  78940. /**
  78941. * The glTF validation options
  78942. */
  78943. interface IGLTFValidationOptions {
  78944. /** Uri to use */
  78945. uri?: string;
  78946. /** Function used to load external resources */
  78947. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78948. /** Boolean indicating that we need to validate accessor data */
  78949. validateAccessorData?: boolean;
  78950. /** max number of issues allowed */
  78951. maxIssues?: number;
  78952. /** Ignored issues */
  78953. ignoredIssues?: Array<string>;
  78954. /** Value to override severy settings */
  78955. severityOverrides?: Object;
  78956. }
  78957. /**
  78958. * The glTF validator object
  78959. * @ignore
  78960. */
  78961. interface IGLTFValidator {
  78962. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78963. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78964. }
  78965. }
  78966. declare module BABYLON {
  78967. /** @hidden */
  78968. export var cellPixelShader: {
  78969. name: string;
  78970. shader: string;
  78971. };
  78972. }
  78973. declare module BABYLON {
  78974. /** @hidden */
  78975. export var cellVertexShader: {
  78976. name: string;
  78977. shader: string;
  78978. };
  78979. }
  78980. declare module BABYLON {
  78981. export class CellMaterial extends BABYLON.PushMaterial {
  78982. private _diffuseTexture;
  78983. diffuseTexture: BABYLON.BaseTexture;
  78984. diffuseColor: BABYLON.Color3;
  78985. _computeHighLevel: boolean;
  78986. computeHighLevel: boolean;
  78987. private _disableLighting;
  78988. disableLighting: boolean;
  78989. private _maxSimultaneousLights;
  78990. maxSimultaneousLights: number;
  78991. private _renderId;
  78992. constructor(name: string, scene: BABYLON.Scene);
  78993. needAlphaBlending(): boolean;
  78994. needAlphaTesting(): boolean;
  78995. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78996. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78997. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78998. getAnimatables(): BABYLON.IAnimatable[];
  78999. getActiveTextures(): BABYLON.BaseTexture[];
  79000. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79001. dispose(forceDisposeEffect?: boolean): void;
  79002. getClassName(): string;
  79003. clone(name: string): CellMaterial;
  79004. serialize(): any;
  79005. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79006. }
  79007. }
  79008. declare module BABYLON {
  79009. export class CustomShaderStructure {
  79010. FragmentStore: string;
  79011. VertexStore: string;
  79012. constructor();
  79013. }
  79014. export class ShaderSpecialParts {
  79015. constructor();
  79016. Fragment_Begin: string;
  79017. Fragment_Definitions: string;
  79018. Fragment_MainBegin: string;
  79019. Fragment_Custom_Diffuse: string;
  79020. Fragment_Before_Lights: string;
  79021. Fragment_Before_Fog: string;
  79022. Fragment_Custom_Alpha: string;
  79023. Fragment_Before_FragColor: string;
  79024. Vertex_Begin: string;
  79025. Vertex_Definitions: string;
  79026. Vertex_MainBegin: string;
  79027. Vertex_Before_PositionUpdated: string;
  79028. Vertex_Before_NormalUpdated: string;
  79029. Vertex_MainEnd: string;
  79030. }
  79031. export class CustomMaterial extends BABYLON.StandardMaterial {
  79032. static ShaderIndexer: number;
  79033. CustomParts: ShaderSpecialParts;
  79034. _isCreatedShader: boolean;
  79035. _createdShaderName: string;
  79036. _customUniform: string[];
  79037. _newUniforms: string[];
  79038. _newUniformInstances: any[];
  79039. _newSamplerInstances: BABYLON.Texture[];
  79040. FragmentShader: string;
  79041. VertexShader: string;
  79042. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79043. ReviewUniform(name: string, arr: string[]): string[];
  79044. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  79045. constructor(name: string, scene: BABYLON.Scene);
  79046. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79047. Fragment_Begin(shaderPart: string): CustomMaterial;
  79048. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79049. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79050. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79051. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79052. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79053. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79054. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79055. Vertex_Begin(shaderPart: string): CustomMaterial;
  79056. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79057. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79058. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79059. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79060. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79061. }
  79062. }
  79063. declare module BABYLON {
  79064. export class ShaderAlebdoParts {
  79065. constructor();
  79066. Fragment_Begin: string;
  79067. Fragment_Definitions: string;
  79068. Fragment_MainBegin: string;
  79069. Fragment_Custom_Albedo: string;
  79070. Fragment_Before_Lights: string;
  79071. Fragment_Custom_MetallicRoughness: string;
  79072. Fragment_Custom_MicroSurface: string;
  79073. Fragment_Before_Fog: string;
  79074. Fragment_Custom_Alpha: string;
  79075. Fragment_Before_FragColor: string;
  79076. Vertex_Begin: string;
  79077. Vertex_Definitions: string;
  79078. Vertex_MainBegin: string;
  79079. Vertex_Before_PositionUpdated: string;
  79080. Vertex_Before_NormalUpdated: string;
  79081. Vertex_MainEnd: string;
  79082. }
  79083. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79084. static ShaderIndexer: number;
  79085. CustomParts: ShaderAlebdoParts;
  79086. _isCreatedShader: boolean;
  79087. _createdShaderName: string;
  79088. _customUniform: string[];
  79089. _newUniforms: string[];
  79090. _newUniformInstances: any[];
  79091. _newSamplerInstances: BABYLON.Texture[];
  79092. FragmentShader: string;
  79093. VertexShader: string;
  79094. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79095. ReviewUniform(name: string, arr: string[]): string[];
  79096. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  79097. constructor(name: string, scene: BABYLON.Scene);
  79098. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79099. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79100. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79101. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79102. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79103. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79104. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79105. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79106. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79107. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79108. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79109. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79110. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79111. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79112. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79113. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79114. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79115. }
  79116. }
  79117. declare module BABYLON {
  79118. /** @hidden */
  79119. export var firePixelShader: {
  79120. name: string;
  79121. shader: string;
  79122. };
  79123. }
  79124. declare module BABYLON {
  79125. /** @hidden */
  79126. export var fireVertexShader: {
  79127. name: string;
  79128. shader: string;
  79129. };
  79130. }
  79131. declare module BABYLON {
  79132. export class FireMaterial extends BABYLON.PushMaterial {
  79133. private _diffuseTexture;
  79134. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79135. private _distortionTexture;
  79136. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79137. private _opacityTexture;
  79138. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79139. diffuseColor: BABYLON.Color3;
  79140. speed: number;
  79141. private _scaledDiffuse;
  79142. private _renderId;
  79143. private _lastTime;
  79144. constructor(name: string, scene: BABYLON.Scene);
  79145. needAlphaBlending(): boolean;
  79146. needAlphaTesting(): boolean;
  79147. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79148. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79149. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79150. getAnimatables(): BABYLON.IAnimatable[];
  79151. getActiveTextures(): BABYLON.BaseTexture[];
  79152. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79153. getClassName(): string;
  79154. dispose(forceDisposeEffect?: boolean): void;
  79155. clone(name: string): FireMaterial;
  79156. serialize(): any;
  79157. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79158. }
  79159. }
  79160. declare module BABYLON {
  79161. /** @hidden */
  79162. export var furPixelShader: {
  79163. name: string;
  79164. shader: string;
  79165. };
  79166. }
  79167. declare module BABYLON {
  79168. /** @hidden */
  79169. export var furVertexShader: {
  79170. name: string;
  79171. shader: string;
  79172. };
  79173. }
  79174. declare module BABYLON {
  79175. export class FurMaterial extends BABYLON.PushMaterial {
  79176. private _diffuseTexture;
  79177. diffuseTexture: BABYLON.BaseTexture;
  79178. private _heightTexture;
  79179. heightTexture: BABYLON.BaseTexture;
  79180. diffuseColor: BABYLON.Color3;
  79181. furLength: number;
  79182. furAngle: number;
  79183. furColor: BABYLON.Color3;
  79184. furOffset: number;
  79185. furSpacing: number;
  79186. furGravity: BABYLON.Vector3;
  79187. furSpeed: number;
  79188. furDensity: number;
  79189. furOcclusion: number;
  79190. furTexture: BABYLON.DynamicTexture;
  79191. private _disableLighting;
  79192. disableLighting: boolean;
  79193. private _maxSimultaneousLights;
  79194. maxSimultaneousLights: number;
  79195. highLevelFur: boolean;
  79196. _meshes: BABYLON.AbstractMesh[];
  79197. private _renderId;
  79198. private _furTime;
  79199. constructor(name: string, scene: BABYLON.Scene);
  79200. get furTime(): number;
  79201. set furTime(furTime: number);
  79202. needAlphaBlending(): boolean;
  79203. needAlphaTesting(): boolean;
  79204. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79205. updateFur(): void;
  79206. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79207. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79208. getAnimatables(): BABYLON.IAnimatable[];
  79209. getActiveTextures(): BABYLON.BaseTexture[];
  79210. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79211. dispose(forceDisposeEffect?: boolean): void;
  79212. clone(name: string): FurMaterial;
  79213. serialize(): any;
  79214. getClassName(): string;
  79215. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79216. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79217. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79218. }
  79219. }
  79220. declare module BABYLON {
  79221. /** @hidden */
  79222. export var gradientPixelShader: {
  79223. name: string;
  79224. shader: string;
  79225. };
  79226. }
  79227. declare module BABYLON {
  79228. /** @hidden */
  79229. export var gradientVertexShader: {
  79230. name: string;
  79231. shader: string;
  79232. };
  79233. }
  79234. declare module BABYLON {
  79235. export class GradientMaterial extends BABYLON.PushMaterial {
  79236. private _maxSimultaneousLights;
  79237. maxSimultaneousLights: number;
  79238. topColor: BABYLON.Color3;
  79239. topColorAlpha: number;
  79240. bottomColor: BABYLON.Color3;
  79241. bottomColorAlpha: number;
  79242. offset: number;
  79243. scale: number;
  79244. smoothness: number;
  79245. private _disableLighting;
  79246. disableLighting: boolean;
  79247. private _renderId;
  79248. constructor(name: string, scene: BABYLON.Scene);
  79249. needAlphaBlending(): boolean;
  79250. needAlphaTesting(): boolean;
  79251. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79252. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79253. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79254. getAnimatables(): BABYLON.IAnimatable[];
  79255. dispose(forceDisposeEffect?: boolean): void;
  79256. clone(name: string): GradientMaterial;
  79257. serialize(): any;
  79258. getClassName(): string;
  79259. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79260. }
  79261. }
  79262. declare module BABYLON {
  79263. /** @hidden */
  79264. export var gridPixelShader: {
  79265. name: string;
  79266. shader: string;
  79267. };
  79268. }
  79269. declare module BABYLON {
  79270. /** @hidden */
  79271. export var gridVertexShader: {
  79272. name: string;
  79273. shader: string;
  79274. };
  79275. }
  79276. declare module BABYLON {
  79277. /**
  79278. * The grid materials allows you to wrap any shape with a grid.
  79279. * Colors are customizable.
  79280. */
  79281. export class GridMaterial extends BABYLON.PushMaterial {
  79282. /**
  79283. * Main color of the grid (e.g. between lines)
  79284. */
  79285. mainColor: BABYLON.Color3;
  79286. /**
  79287. * Color of the grid lines.
  79288. */
  79289. lineColor: BABYLON.Color3;
  79290. /**
  79291. * The scale of the grid compared to unit.
  79292. */
  79293. gridRatio: number;
  79294. /**
  79295. * Allows setting an offset for the grid lines.
  79296. */
  79297. gridOffset: BABYLON.Vector3;
  79298. /**
  79299. * The frequency of thicker lines.
  79300. */
  79301. majorUnitFrequency: number;
  79302. /**
  79303. * The visibility of minor units in the grid.
  79304. */
  79305. minorUnitVisibility: number;
  79306. /**
  79307. * The grid opacity outside of the lines.
  79308. */
  79309. opacity: number;
  79310. /**
  79311. * Determine RBG output is premultiplied by alpha value.
  79312. */
  79313. preMultiplyAlpha: boolean;
  79314. private _opacityTexture;
  79315. opacityTexture: BABYLON.BaseTexture;
  79316. private _gridControl;
  79317. private _renderId;
  79318. /**
  79319. * constructor
  79320. * @param name The name given to the material in order to identify it afterwards.
  79321. * @param scene The scene the material is used in.
  79322. */
  79323. constructor(name: string, scene: BABYLON.Scene);
  79324. /**
  79325. * Returns wehter or not the grid requires alpha blending.
  79326. */
  79327. needAlphaBlending(): boolean;
  79328. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79329. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79330. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79331. /**
  79332. * Dispose the material and its associated resources.
  79333. * @param forceDisposeEffect will also dispose the used effect when true
  79334. */
  79335. dispose(forceDisposeEffect?: boolean): void;
  79336. clone(name: string): GridMaterial;
  79337. serialize(): any;
  79338. getClassName(): string;
  79339. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79340. }
  79341. }
  79342. declare module BABYLON {
  79343. /** @hidden */
  79344. export var lavaPixelShader: {
  79345. name: string;
  79346. shader: string;
  79347. };
  79348. }
  79349. declare module BABYLON {
  79350. /** @hidden */
  79351. export var lavaVertexShader: {
  79352. name: string;
  79353. shader: string;
  79354. };
  79355. }
  79356. declare module BABYLON {
  79357. export class LavaMaterial extends BABYLON.PushMaterial {
  79358. private _diffuseTexture;
  79359. diffuseTexture: BABYLON.BaseTexture;
  79360. noiseTexture: BABYLON.BaseTexture;
  79361. fogColor: BABYLON.Color3;
  79362. speed: number;
  79363. movingSpeed: number;
  79364. lowFrequencySpeed: number;
  79365. fogDensity: number;
  79366. private _lastTime;
  79367. diffuseColor: BABYLON.Color3;
  79368. private _disableLighting;
  79369. disableLighting: boolean;
  79370. private _unlit;
  79371. unlit: boolean;
  79372. private _maxSimultaneousLights;
  79373. maxSimultaneousLights: number;
  79374. private _scaledDiffuse;
  79375. private _renderId;
  79376. constructor(name: string, scene: BABYLON.Scene);
  79377. needAlphaBlending(): boolean;
  79378. needAlphaTesting(): boolean;
  79379. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79380. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79381. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79382. getAnimatables(): BABYLON.IAnimatable[];
  79383. getActiveTextures(): BABYLON.BaseTexture[];
  79384. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79385. dispose(forceDisposeEffect?: boolean): void;
  79386. clone(name: string): LavaMaterial;
  79387. serialize(): any;
  79388. getClassName(): string;
  79389. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79390. }
  79391. }
  79392. declare module BABYLON {
  79393. /** @hidden */
  79394. export var mixPixelShader: {
  79395. name: string;
  79396. shader: string;
  79397. };
  79398. }
  79399. declare module BABYLON {
  79400. /** @hidden */
  79401. export var mixVertexShader: {
  79402. name: string;
  79403. shader: string;
  79404. };
  79405. }
  79406. declare module BABYLON {
  79407. export class MixMaterial extends BABYLON.PushMaterial {
  79408. /**
  79409. * Mix textures
  79410. */
  79411. private _mixTexture1;
  79412. mixTexture1: BABYLON.BaseTexture;
  79413. private _mixTexture2;
  79414. mixTexture2: BABYLON.BaseTexture;
  79415. /**
  79416. * Diffuse textures
  79417. */
  79418. private _diffuseTexture1;
  79419. diffuseTexture1: BABYLON.Texture;
  79420. private _diffuseTexture2;
  79421. diffuseTexture2: BABYLON.Texture;
  79422. private _diffuseTexture3;
  79423. diffuseTexture3: BABYLON.Texture;
  79424. private _diffuseTexture4;
  79425. diffuseTexture4: BABYLON.Texture;
  79426. private _diffuseTexture5;
  79427. diffuseTexture5: BABYLON.Texture;
  79428. private _diffuseTexture6;
  79429. diffuseTexture6: BABYLON.Texture;
  79430. private _diffuseTexture7;
  79431. diffuseTexture7: BABYLON.Texture;
  79432. private _diffuseTexture8;
  79433. diffuseTexture8: BABYLON.Texture;
  79434. /**
  79435. * Uniforms
  79436. */
  79437. diffuseColor: BABYLON.Color3;
  79438. specularColor: BABYLON.Color3;
  79439. specularPower: number;
  79440. private _disableLighting;
  79441. disableLighting: boolean;
  79442. private _maxSimultaneousLights;
  79443. maxSimultaneousLights: number;
  79444. private _renderId;
  79445. constructor(name: string, scene: BABYLON.Scene);
  79446. needAlphaBlending(): boolean;
  79447. needAlphaTesting(): boolean;
  79448. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79449. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79450. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79451. getAnimatables(): BABYLON.IAnimatable[];
  79452. getActiveTextures(): BABYLON.BaseTexture[];
  79453. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79454. dispose(forceDisposeEffect?: boolean): void;
  79455. clone(name: string): MixMaterial;
  79456. serialize(): any;
  79457. getClassName(): string;
  79458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79459. }
  79460. }
  79461. declare module BABYLON {
  79462. /** @hidden */
  79463. export var normalPixelShader: {
  79464. name: string;
  79465. shader: string;
  79466. };
  79467. }
  79468. declare module BABYLON {
  79469. /** @hidden */
  79470. export var normalVertexShader: {
  79471. name: string;
  79472. shader: string;
  79473. };
  79474. }
  79475. declare module BABYLON {
  79476. export class NormalMaterial extends BABYLON.PushMaterial {
  79477. private _diffuseTexture;
  79478. diffuseTexture: BABYLON.BaseTexture;
  79479. diffuseColor: BABYLON.Color3;
  79480. private _disableLighting;
  79481. disableLighting: boolean;
  79482. private _maxSimultaneousLights;
  79483. maxSimultaneousLights: number;
  79484. private _renderId;
  79485. constructor(name: string, scene: BABYLON.Scene);
  79486. needAlphaBlending(): boolean;
  79487. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79488. needAlphaTesting(): boolean;
  79489. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79490. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79491. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79492. getAnimatables(): BABYLON.IAnimatable[];
  79493. getActiveTextures(): BABYLON.BaseTexture[];
  79494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79495. dispose(forceDisposeEffect?: boolean): void;
  79496. clone(name: string): NormalMaterial;
  79497. serialize(): any;
  79498. getClassName(): string;
  79499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79500. }
  79501. }
  79502. declare module BABYLON {
  79503. /** @hidden */
  79504. export var shadowOnlyPixelShader: {
  79505. name: string;
  79506. shader: string;
  79507. };
  79508. }
  79509. declare module BABYLON {
  79510. /** @hidden */
  79511. export var shadowOnlyVertexShader: {
  79512. name: string;
  79513. shader: string;
  79514. };
  79515. }
  79516. declare module BABYLON {
  79517. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79518. private _renderId;
  79519. private _activeLight;
  79520. constructor(name: string, scene: BABYLON.Scene);
  79521. shadowColor: BABYLON.Color3;
  79522. needAlphaBlending(): boolean;
  79523. needAlphaTesting(): boolean;
  79524. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79525. get activeLight(): BABYLON.IShadowLight;
  79526. set activeLight(light: BABYLON.IShadowLight);
  79527. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79528. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79529. clone(name: string): ShadowOnlyMaterial;
  79530. serialize(): any;
  79531. getClassName(): string;
  79532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79533. }
  79534. }
  79535. declare module BABYLON {
  79536. /** @hidden */
  79537. export var simplePixelShader: {
  79538. name: string;
  79539. shader: string;
  79540. };
  79541. }
  79542. declare module BABYLON {
  79543. /** @hidden */
  79544. export var simpleVertexShader: {
  79545. name: string;
  79546. shader: string;
  79547. };
  79548. }
  79549. declare module BABYLON {
  79550. export class SimpleMaterial extends BABYLON.PushMaterial {
  79551. private _diffuseTexture;
  79552. diffuseTexture: BABYLON.BaseTexture;
  79553. diffuseColor: BABYLON.Color3;
  79554. private _disableLighting;
  79555. disableLighting: boolean;
  79556. private _maxSimultaneousLights;
  79557. maxSimultaneousLights: number;
  79558. private _renderId;
  79559. constructor(name: string, scene: BABYLON.Scene);
  79560. needAlphaBlending(): boolean;
  79561. needAlphaTesting(): boolean;
  79562. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79563. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79564. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79565. getAnimatables(): BABYLON.IAnimatable[];
  79566. getActiveTextures(): BABYLON.BaseTexture[];
  79567. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79568. dispose(forceDisposeEffect?: boolean): void;
  79569. clone(name: string): SimpleMaterial;
  79570. serialize(): any;
  79571. getClassName(): string;
  79572. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79573. }
  79574. }
  79575. declare module BABYLON {
  79576. /** @hidden */
  79577. export var skyPixelShader: {
  79578. name: string;
  79579. shader: string;
  79580. };
  79581. }
  79582. declare module BABYLON {
  79583. /** @hidden */
  79584. export var skyVertexShader: {
  79585. name: string;
  79586. shader: string;
  79587. };
  79588. }
  79589. declare module BABYLON {
  79590. /**
  79591. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79592. * @see https://doc.babylonjs.com/extensions/sky
  79593. */
  79594. export class SkyMaterial extends BABYLON.PushMaterial {
  79595. /**
  79596. * Defines the overall luminance of sky in interval ]0, 1[.
  79597. */
  79598. luminance: number;
  79599. /**
  79600. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79601. */
  79602. turbidity: number;
  79603. /**
  79604. * Defines the sky appearance (light intensity).
  79605. */
  79606. rayleigh: number;
  79607. /**
  79608. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79609. */
  79610. mieCoefficient: number;
  79611. /**
  79612. * Defines the amount of haze particles following the Mie scattering theory.
  79613. */
  79614. mieDirectionalG: number;
  79615. /**
  79616. * Defines the distance of the sun according to the active scene camera.
  79617. */
  79618. distance: number;
  79619. /**
  79620. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79621. * "inclined".
  79622. */
  79623. inclination: number;
  79624. /**
  79625. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79626. * an object direction and a reference direction.
  79627. */
  79628. azimuth: number;
  79629. /**
  79630. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79631. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79632. */
  79633. sunPosition: BABYLON.Vector3;
  79634. /**
  79635. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79636. * .sunPosition property.
  79637. */
  79638. useSunPosition: boolean;
  79639. /**
  79640. * Defines an offset vector used to get a horizon offset.
  79641. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79642. */
  79643. cameraOffset: BABYLON.Vector3;
  79644. private _cameraPosition;
  79645. private _renderId;
  79646. /**
  79647. * Instantiates a new sky material.
  79648. * This material allows to create dynamic and texture free
  79649. * effects for skyboxes by taking care of the atmosphere state.
  79650. * @see https://doc.babylonjs.com/extensions/sky
  79651. * @param name Define the name of the material in the scene
  79652. * @param scene Define the scene the material belong to
  79653. */
  79654. constructor(name: string, scene: BABYLON.Scene);
  79655. /**
  79656. * Specifies if the material will require alpha blending
  79657. * @returns a boolean specifying if alpha blending is needed
  79658. */
  79659. needAlphaBlending(): boolean;
  79660. /**
  79661. * Specifies if this material should be rendered in alpha test mode
  79662. * @returns false as the sky material doesn't need alpha testing.
  79663. */
  79664. needAlphaTesting(): boolean;
  79665. /**
  79666. * Get the texture used for alpha test purpose.
  79667. * @returns null as the sky material has no texture.
  79668. */
  79669. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79670. /**
  79671. * Get if the submesh is ready to be used and all its information available.
  79672. * Child classes can use it to update shaders
  79673. * @param mesh defines the mesh to check
  79674. * @param subMesh defines which submesh to check
  79675. * @param useInstances specifies that instances should be used
  79676. * @returns a boolean indicating that the submesh is ready or not
  79677. */
  79678. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79679. /**
  79680. * Binds the submesh to this material by preparing the effect and shader to draw
  79681. * @param world defines the world transformation matrix
  79682. * @param mesh defines the mesh containing the submesh
  79683. * @param subMesh defines the submesh to bind the material to
  79684. */
  79685. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79686. /**
  79687. * Get the list of animatables in the material.
  79688. * @returns the list of animatables object used in the material
  79689. */
  79690. getAnimatables(): BABYLON.IAnimatable[];
  79691. /**
  79692. * Disposes the material
  79693. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79694. */
  79695. dispose(forceDisposeEffect?: boolean): void;
  79696. /**
  79697. * Makes a duplicate of the material, and gives it a new name
  79698. * @param name defines the new name for the duplicated material
  79699. * @returns the cloned material
  79700. */
  79701. clone(name: string): SkyMaterial;
  79702. /**
  79703. * Serializes this material in a JSON representation
  79704. * @returns the serialized material object
  79705. */
  79706. serialize(): any;
  79707. /**
  79708. * Gets the current class name of the material e.g. "SkyMaterial"
  79709. * Mainly use in serialization.
  79710. * @returns the class name
  79711. */
  79712. getClassName(): string;
  79713. /**
  79714. * Creates a sky material from parsed material data
  79715. * @param source defines the JSON representation of the material
  79716. * @param scene defines the hosting scene
  79717. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79718. * @returns a new sky material
  79719. */
  79720. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79721. }
  79722. }
  79723. declare module BABYLON {
  79724. /** @hidden */
  79725. export var terrainPixelShader: {
  79726. name: string;
  79727. shader: string;
  79728. };
  79729. }
  79730. declare module BABYLON {
  79731. /** @hidden */
  79732. export var terrainVertexShader: {
  79733. name: string;
  79734. shader: string;
  79735. };
  79736. }
  79737. declare module BABYLON {
  79738. export class TerrainMaterial extends BABYLON.PushMaterial {
  79739. private _mixTexture;
  79740. mixTexture: BABYLON.BaseTexture;
  79741. private _diffuseTexture1;
  79742. diffuseTexture1: BABYLON.Texture;
  79743. private _diffuseTexture2;
  79744. diffuseTexture2: BABYLON.Texture;
  79745. private _diffuseTexture3;
  79746. diffuseTexture3: BABYLON.Texture;
  79747. private _bumpTexture1;
  79748. bumpTexture1: BABYLON.Texture;
  79749. private _bumpTexture2;
  79750. bumpTexture2: BABYLON.Texture;
  79751. private _bumpTexture3;
  79752. bumpTexture3: BABYLON.Texture;
  79753. diffuseColor: BABYLON.Color3;
  79754. specularColor: BABYLON.Color3;
  79755. specularPower: number;
  79756. private _disableLighting;
  79757. disableLighting: boolean;
  79758. private _maxSimultaneousLights;
  79759. maxSimultaneousLights: number;
  79760. private _renderId;
  79761. constructor(name: string, scene: BABYLON.Scene);
  79762. needAlphaBlending(): boolean;
  79763. needAlphaTesting(): boolean;
  79764. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79765. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79766. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79767. getAnimatables(): BABYLON.IAnimatable[];
  79768. getActiveTextures(): BABYLON.BaseTexture[];
  79769. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79770. dispose(forceDisposeEffect?: boolean): void;
  79771. clone(name: string): TerrainMaterial;
  79772. serialize(): any;
  79773. getClassName(): string;
  79774. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79775. }
  79776. }
  79777. declare module BABYLON {
  79778. /** @hidden */
  79779. export var triplanarPixelShader: {
  79780. name: string;
  79781. shader: string;
  79782. };
  79783. }
  79784. declare module BABYLON {
  79785. /** @hidden */
  79786. export var triplanarVertexShader: {
  79787. name: string;
  79788. shader: string;
  79789. };
  79790. }
  79791. declare module BABYLON {
  79792. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79793. mixTexture: BABYLON.BaseTexture;
  79794. private _diffuseTextureX;
  79795. diffuseTextureX: BABYLON.BaseTexture;
  79796. private _diffuseTextureY;
  79797. diffuseTextureY: BABYLON.BaseTexture;
  79798. private _diffuseTextureZ;
  79799. diffuseTextureZ: BABYLON.BaseTexture;
  79800. private _normalTextureX;
  79801. normalTextureX: BABYLON.BaseTexture;
  79802. private _normalTextureY;
  79803. normalTextureY: BABYLON.BaseTexture;
  79804. private _normalTextureZ;
  79805. normalTextureZ: BABYLON.BaseTexture;
  79806. tileSize: number;
  79807. diffuseColor: BABYLON.Color3;
  79808. specularColor: BABYLON.Color3;
  79809. specularPower: number;
  79810. private _disableLighting;
  79811. disableLighting: boolean;
  79812. private _maxSimultaneousLights;
  79813. maxSimultaneousLights: number;
  79814. private _renderId;
  79815. constructor(name: string, scene: BABYLON.Scene);
  79816. needAlphaBlending(): boolean;
  79817. needAlphaTesting(): boolean;
  79818. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79819. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79820. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79821. getAnimatables(): BABYLON.IAnimatable[];
  79822. getActiveTextures(): BABYLON.BaseTexture[];
  79823. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79824. dispose(forceDisposeEffect?: boolean): void;
  79825. clone(name: string): TriPlanarMaterial;
  79826. serialize(): any;
  79827. getClassName(): string;
  79828. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79829. }
  79830. }
  79831. declare module BABYLON {
  79832. /** @hidden */
  79833. export var waterPixelShader: {
  79834. name: string;
  79835. shader: string;
  79836. };
  79837. }
  79838. declare module BABYLON {
  79839. /** @hidden */
  79840. export var waterVertexShader: {
  79841. name: string;
  79842. shader: string;
  79843. };
  79844. }
  79845. declare module BABYLON {
  79846. export class WaterMaterial extends BABYLON.PushMaterial {
  79847. renderTargetSize: BABYLON.Vector2;
  79848. private _bumpTexture;
  79849. bumpTexture: BABYLON.BaseTexture;
  79850. diffuseColor: BABYLON.Color3;
  79851. specularColor: BABYLON.Color3;
  79852. specularPower: number;
  79853. private _disableLighting;
  79854. disableLighting: boolean;
  79855. private _maxSimultaneousLights;
  79856. maxSimultaneousLights: number;
  79857. /**
  79858. * @param {number}: Represents the wind force
  79859. */
  79860. windForce: number;
  79861. /**
  79862. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79863. */
  79864. windDirection: BABYLON.Vector2;
  79865. /**
  79866. * @param {number}: Wave height, represents the height of the waves
  79867. */
  79868. waveHeight: number;
  79869. /**
  79870. * @param {number}: Bump height, represents the bump height related to the bump map
  79871. */
  79872. bumpHeight: number;
  79873. /**
  79874. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79875. */
  79876. private _bumpSuperimpose;
  79877. bumpSuperimpose: boolean;
  79878. /**
  79879. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79880. */
  79881. private _fresnelSeparate;
  79882. fresnelSeparate: boolean;
  79883. /**
  79884. * @param {boolean}: bump Waves modify the reflection.
  79885. */
  79886. private _bumpAffectsReflection;
  79887. bumpAffectsReflection: boolean;
  79888. /**
  79889. * @param {number}: The water color blended with the refraction (near)
  79890. */
  79891. waterColor: BABYLON.Color3;
  79892. /**
  79893. * @param {number}: The blend factor related to the water color
  79894. */
  79895. colorBlendFactor: number;
  79896. /**
  79897. * @param {number}: The water color blended with the reflection (far)
  79898. */
  79899. waterColor2: BABYLON.Color3;
  79900. /**
  79901. * @param {number}: The blend factor related to the water color (reflection, far)
  79902. */
  79903. colorBlendFactor2: number;
  79904. /**
  79905. * @param {number}: Represents the maximum length of a wave
  79906. */
  79907. waveLength: number;
  79908. /**
  79909. * @param {number}: Defines the waves speed
  79910. */
  79911. waveSpeed: number;
  79912. /**
  79913. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79914. * will avoid calculating useless pixels in the pixel shader of the water material.
  79915. */
  79916. disableClipPlane: boolean;
  79917. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79918. private _mesh;
  79919. private _refractionRTT;
  79920. private _reflectionRTT;
  79921. private _reflectionTransform;
  79922. private _lastTime;
  79923. private _lastDeltaTime;
  79924. private _renderId;
  79925. private _useLogarithmicDepth;
  79926. private _waitingRenderList;
  79927. private _imageProcessingConfiguration;
  79928. private _imageProcessingObserver;
  79929. /**
  79930. * Gets a boolean indicating that current material needs to register RTT
  79931. */
  79932. get hasRenderTargetTextures(): boolean;
  79933. /**
  79934. * Constructor
  79935. */
  79936. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79937. get useLogarithmicDepth(): boolean;
  79938. set useLogarithmicDepth(value: boolean);
  79939. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79940. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79941. addToRenderList(node: any): void;
  79942. enableRenderTargets(enable: boolean): void;
  79943. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79944. get renderTargetsEnabled(): boolean;
  79945. needAlphaBlending(): boolean;
  79946. needAlphaTesting(): boolean;
  79947. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79948. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79949. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79950. private _createRenderTargets;
  79951. getAnimatables(): BABYLON.IAnimatable[];
  79952. getActiveTextures(): BABYLON.BaseTexture[];
  79953. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79954. dispose(forceDisposeEffect?: boolean): void;
  79955. clone(name: string): WaterMaterial;
  79956. serialize(): any;
  79957. getClassName(): string;
  79958. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79959. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79960. }
  79961. }
  79962. declare module BABYLON {
  79963. /** @hidden */
  79964. export var asciiartPixelShader: {
  79965. name: string;
  79966. shader: string;
  79967. };
  79968. }
  79969. declare module BABYLON {
  79970. /**
  79971. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79972. *
  79973. * It basically takes care rendering the font front the given font size to a texture.
  79974. * This is used later on in the postprocess.
  79975. */
  79976. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79977. private _font;
  79978. private _text;
  79979. private _charSize;
  79980. /**
  79981. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79982. */
  79983. get charSize(): number;
  79984. /**
  79985. * Create a new instance of the Ascii Art FontTexture class
  79986. * @param name the name of the texture
  79987. * @param font the font to use, use the W3C CSS notation
  79988. * @param text the caracter set to use in the rendering.
  79989. * @param scene the scene that owns the texture
  79990. */
  79991. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79992. /**
  79993. * Gets the max char width of a font.
  79994. * @param font the font to use, use the W3C CSS notation
  79995. * @return the max char width
  79996. */
  79997. private getFontWidth;
  79998. /**
  79999. * Gets the max char height of a font.
  80000. * @param font the font to use, use the W3C CSS notation
  80001. * @return the max char height
  80002. */
  80003. private getFontHeight;
  80004. /**
  80005. * Clones the current AsciiArtTexture.
  80006. * @return the clone of the texture.
  80007. */
  80008. clone(): AsciiArtFontTexture;
  80009. /**
  80010. * Parses a json object representing the texture and returns an instance of it.
  80011. * @param source the source JSON representation
  80012. * @param scene the scene to create the texture for
  80013. * @return the parsed texture
  80014. */
  80015. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80016. }
  80017. /**
  80018. * Option available in the Ascii Art Post Process.
  80019. */
  80020. export interface IAsciiArtPostProcessOptions {
  80021. /**
  80022. * The font to use following the w3c font definition.
  80023. */
  80024. font?: string;
  80025. /**
  80026. * The character set to use in the postprocess.
  80027. */
  80028. characterSet?: string;
  80029. /**
  80030. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80031. * This number is defined between 0 and 1;
  80032. */
  80033. mixToTile?: number;
  80034. /**
  80035. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80036. * This number is defined between 0 and 1;
  80037. */
  80038. mixToNormal?: number;
  80039. }
  80040. /**
  80041. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80042. *
  80043. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80044. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80045. */
  80046. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80047. /**
  80048. * The font texture used to render the char in the post process.
  80049. */
  80050. private _asciiArtFontTexture;
  80051. /**
  80052. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80053. * This number is defined between 0 and 1;
  80054. */
  80055. mixToTile: number;
  80056. /**
  80057. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80058. * This number is defined between 0 and 1;
  80059. */
  80060. mixToNormal: number;
  80061. /**
  80062. * Instantiates a new Ascii Art Post Process.
  80063. * @param name the name to give to the postprocess
  80064. * @camera the camera to apply the post process to.
  80065. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80066. */
  80067. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80068. }
  80069. }
  80070. declare module BABYLON {
  80071. /** @hidden */
  80072. export var digitalrainPixelShader: {
  80073. name: string;
  80074. shader: string;
  80075. };
  80076. }
  80077. declare module BABYLON {
  80078. /**
  80079. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80080. *
  80081. * It basically takes care rendering the font front the given font size to a texture.
  80082. * This is used later on in the postprocess.
  80083. */
  80084. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80085. private _font;
  80086. private _text;
  80087. private _charSize;
  80088. /**
  80089. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80090. */
  80091. get charSize(): number;
  80092. /**
  80093. * Create a new instance of the Digital Rain FontTexture class
  80094. * @param name the name of the texture
  80095. * @param font the font to use, use the W3C CSS notation
  80096. * @param text the caracter set to use in the rendering.
  80097. * @param scene the scene that owns the texture
  80098. */
  80099. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80100. /**
  80101. * Gets the max char width of a font.
  80102. * @param font the font to use, use the W3C CSS notation
  80103. * @return the max char width
  80104. */
  80105. private getFontWidth;
  80106. /**
  80107. * Gets the max char height of a font.
  80108. * @param font the font to use, use the W3C CSS notation
  80109. * @return the max char height
  80110. */
  80111. private getFontHeight;
  80112. /**
  80113. * Clones the current DigitalRainFontTexture.
  80114. * @return the clone of the texture.
  80115. */
  80116. clone(): DigitalRainFontTexture;
  80117. /**
  80118. * Parses a json object representing the texture and returns an instance of it.
  80119. * @param source the source JSON representation
  80120. * @param scene the scene to create the texture for
  80121. * @return the parsed texture
  80122. */
  80123. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80124. }
  80125. /**
  80126. * Option available in the Digital Rain Post Process.
  80127. */
  80128. export interface IDigitalRainPostProcessOptions {
  80129. /**
  80130. * The font to use following the w3c font definition.
  80131. */
  80132. font?: string;
  80133. /**
  80134. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80135. * This number is defined between 0 and 1;
  80136. */
  80137. mixToTile?: number;
  80138. /**
  80139. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80140. * This number is defined between 0 and 1;
  80141. */
  80142. mixToNormal?: number;
  80143. }
  80144. /**
  80145. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80146. *
  80147. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80148. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80149. */
  80150. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80151. /**
  80152. * The font texture used to render the char in the post process.
  80153. */
  80154. private _digitalRainFontTexture;
  80155. /**
  80156. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80157. * This number is defined between 0 and 1;
  80158. */
  80159. mixToTile: number;
  80160. /**
  80161. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80162. * This number is defined between 0 and 1;
  80163. */
  80164. mixToNormal: number;
  80165. /**
  80166. * Instantiates a new Digital Rain Post Process.
  80167. * @param name the name to give to the postprocess
  80168. * @camera the camera to apply the post process to.
  80169. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80170. */
  80171. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80172. }
  80173. }
  80174. declare module BABYLON {
  80175. /** @hidden */
  80176. export var brickProceduralTexturePixelShader: {
  80177. name: string;
  80178. shader: string;
  80179. };
  80180. }
  80181. declare module BABYLON {
  80182. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80183. private _numberOfBricksHeight;
  80184. private _numberOfBricksWidth;
  80185. private _jointColor;
  80186. private _brickColor;
  80187. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80188. updateShaderUniforms(): void;
  80189. get numberOfBricksHeight(): number;
  80190. set numberOfBricksHeight(value: number);
  80191. get numberOfBricksWidth(): number;
  80192. set numberOfBricksWidth(value: number);
  80193. get jointColor(): BABYLON.Color3;
  80194. set jointColor(value: BABYLON.Color3);
  80195. get brickColor(): BABYLON.Color3;
  80196. set brickColor(value: BABYLON.Color3);
  80197. /**
  80198. * Serializes this brick procedural texture
  80199. * @returns a serialized brick procedural texture object
  80200. */
  80201. serialize(): any;
  80202. /**
  80203. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80204. * @param parsedTexture defines parsed texture data
  80205. * @param scene defines the current scene
  80206. * @param rootUrl defines the root URL containing brick procedural texture information
  80207. * @returns a parsed Brick Procedural BABYLON.Texture
  80208. */
  80209. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80210. }
  80211. }
  80212. declare module BABYLON {
  80213. /** @hidden */
  80214. export var cloudProceduralTexturePixelShader: {
  80215. name: string;
  80216. shader: string;
  80217. };
  80218. }
  80219. declare module BABYLON {
  80220. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80221. private _skyColor;
  80222. private _cloudColor;
  80223. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80224. updateShaderUniforms(): void;
  80225. get skyColor(): BABYLON.Color4;
  80226. set skyColor(value: BABYLON.Color4);
  80227. get cloudColor(): BABYLON.Color4;
  80228. set cloudColor(value: BABYLON.Color4);
  80229. /**
  80230. * Serializes this cloud procedural texture
  80231. * @returns a serialized cloud procedural texture object
  80232. */
  80233. serialize(): any;
  80234. /**
  80235. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80236. * @param parsedTexture defines parsed texture data
  80237. * @param scene defines the current scene
  80238. * @param rootUrl defines the root URL containing cloud procedural texture information
  80239. * @returns a parsed Cloud Procedural BABYLON.Texture
  80240. */
  80241. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80242. }
  80243. }
  80244. declare module BABYLON {
  80245. /** @hidden */
  80246. export var fireProceduralTexturePixelShader: {
  80247. name: string;
  80248. shader: string;
  80249. };
  80250. }
  80251. declare module BABYLON {
  80252. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80253. private _time;
  80254. private _speed;
  80255. private _autoGenerateTime;
  80256. private _fireColors;
  80257. private _alphaThreshold;
  80258. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80259. updateShaderUniforms(): void;
  80260. render(useCameraPostProcess?: boolean): void;
  80261. static get PurpleFireColors(): BABYLON.Color3[];
  80262. static get GreenFireColors(): BABYLON.Color3[];
  80263. static get RedFireColors(): BABYLON.Color3[];
  80264. static get BlueFireColors(): BABYLON.Color3[];
  80265. get autoGenerateTime(): boolean;
  80266. set autoGenerateTime(value: boolean);
  80267. get fireColors(): BABYLON.Color3[];
  80268. set fireColors(value: BABYLON.Color3[]);
  80269. get time(): number;
  80270. set time(value: number);
  80271. get speed(): BABYLON.Vector2;
  80272. set speed(value: BABYLON.Vector2);
  80273. get alphaThreshold(): number;
  80274. set alphaThreshold(value: number);
  80275. /**
  80276. * Serializes this fire procedural texture
  80277. * @returns a serialized fire procedural texture object
  80278. */
  80279. serialize(): any;
  80280. /**
  80281. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80282. * @param parsedTexture defines parsed texture data
  80283. * @param scene defines the current scene
  80284. * @param rootUrl defines the root URL containing fire procedural texture information
  80285. * @returns a parsed Fire Procedural BABYLON.Texture
  80286. */
  80287. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80288. }
  80289. }
  80290. declare module BABYLON {
  80291. /** @hidden */
  80292. export var grassProceduralTexturePixelShader: {
  80293. name: string;
  80294. shader: string;
  80295. };
  80296. }
  80297. declare module BABYLON {
  80298. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80299. private _grassColors;
  80300. private _groundColor;
  80301. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80302. updateShaderUniforms(): void;
  80303. get grassColors(): BABYLON.Color3[];
  80304. set grassColors(value: BABYLON.Color3[]);
  80305. get groundColor(): BABYLON.Color3;
  80306. set groundColor(value: BABYLON.Color3);
  80307. /**
  80308. * Serializes this grass procedural texture
  80309. * @returns a serialized grass procedural texture object
  80310. */
  80311. serialize(): any;
  80312. /**
  80313. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80314. * @param parsedTexture defines parsed texture data
  80315. * @param scene defines the current scene
  80316. * @param rootUrl defines the root URL containing grass procedural texture information
  80317. * @returns a parsed Grass Procedural BABYLON.Texture
  80318. */
  80319. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80320. }
  80321. }
  80322. declare module BABYLON {
  80323. /** @hidden */
  80324. export var marbleProceduralTexturePixelShader: {
  80325. name: string;
  80326. shader: string;
  80327. };
  80328. }
  80329. declare module BABYLON {
  80330. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80331. private _numberOfTilesHeight;
  80332. private _numberOfTilesWidth;
  80333. private _amplitude;
  80334. private _jointColor;
  80335. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80336. updateShaderUniforms(): void;
  80337. get numberOfTilesHeight(): number;
  80338. set numberOfTilesHeight(value: number);
  80339. get amplitude(): number;
  80340. set amplitude(value: number);
  80341. get numberOfTilesWidth(): number;
  80342. set numberOfTilesWidth(value: number);
  80343. get jointColor(): BABYLON.Color3;
  80344. set jointColor(value: BABYLON.Color3);
  80345. /**
  80346. * Serializes this marble procedural texture
  80347. * @returns a serialized marble procedural texture object
  80348. */
  80349. serialize(): any;
  80350. /**
  80351. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80352. * @param parsedTexture defines parsed texture data
  80353. * @param scene defines the current scene
  80354. * @param rootUrl defines the root URL containing marble procedural texture information
  80355. * @returns a parsed Marble Procedural BABYLON.Texture
  80356. */
  80357. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80358. }
  80359. }
  80360. declare module BABYLON {
  80361. /** @hidden */
  80362. export var normalMapProceduralTexturePixelShader: {
  80363. name: string;
  80364. shader: string;
  80365. };
  80366. }
  80367. declare module BABYLON {
  80368. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80369. private _baseTexture;
  80370. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80371. updateShaderUniforms(): void;
  80372. render(useCameraPostProcess?: boolean): void;
  80373. resize(size: any, generateMipMaps: any): void;
  80374. get baseTexture(): BABYLON.Texture;
  80375. set baseTexture(texture: BABYLON.Texture);
  80376. /**
  80377. * Serializes this normal map procedural texture
  80378. * @returns a serialized normal map procedural texture object
  80379. */
  80380. serialize(): any;
  80381. /**
  80382. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80383. * @param parsedTexture defines parsed texture data
  80384. * @param scene defines the current scene
  80385. * @param rootUrl defines the root URL containing normal map procedural texture information
  80386. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80387. */
  80388. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80389. }
  80390. }
  80391. declare module BABYLON {
  80392. /** @hidden */
  80393. export var perlinNoiseProceduralTexturePixelShader: {
  80394. name: string;
  80395. shader: string;
  80396. };
  80397. }
  80398. declare module BABYLON {
  80399. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80400. time: number;
  80401. timeScale: number;
  80402. translationSpeed: number;
  80403. private _currentTranslation;
  80404. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80405. updateShaderUniforms(): void;
  80406. render(useCameraPostProcess?: boolean): void;
  80407. resize(size: any, generateMipMaps: any): void;
  80408. /**
  80409. * Serializes this perlin noise procedural texture
  80410. * @returns a serialized perlin noise procedural texture object
  80411. */
  80412. serialize(): any;
  80413. /**
  80414. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80415. * @param parsedTexture defines parsed texture data
  80416. * @param scene defines the current scene
  80417. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80418. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80419. */
  80420. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80421. }
  80422. }
  80423. declare module BABYLON {
  80424. /** @hidden */
  80425. export var roadProceduralTexturePixelShader: {
  80426. name: string;
  80427. shader: string;
  80428. };
  80429. }
  80430. declare module BABYLON {
  80431. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80432. private _roadColor;
  80433. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80434. updateShaderUniforms(): void;
  80435. get roadColor(): BABYLON.Color3;
  80436. set roadColor(value: BABYLON.Color3);
  80437. /**
  80438. * Serializes this road procedural texture
  80439. * @returns a serialized road procedural texture object
  80440. */
  80441. serialize(): any;
  80442. /**
  80443. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80444. * @param parsedTexture defines parsed texture data
  80445. * @param scene defines the current scene
  80446. * @param rootUrl defines the root URL containing road procedural texture information
  80447. * @returns a parsed Road Procedural BABYLON.Texture
  80448. */
  80449. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80450. }
  80451. }
  80452. declare module BABYLON {
  80453. /** @hidden */
  80454. export var starfieldProceduralTexturePixelShader: {
  80455. name: string;
  80456. shader: string;
  80457. };
  80458. }
  80459. declare module BABYLON {
  80460. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80461. private _time;
  80462. private _alpha;
  80463. private _beta;
  80464. private _zoom;
  80465. private _formuparam;
  80466. private _stepsize;
  80467. private _tile;
  80468. private _brightness;
  80469. private _darkmatter;
  80470. private _distfading;
  80471. private _saturation;
  80472. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80473. updateShaderUniforms(): void;
  80474. get time(): number;
  80475. set time(value: number);
  80476. get alpha(): number;
  80477. set alpha(value: number);
  80478. get beta(): number;
  80479. set beta(value: number);
  80480. get formuparam(): number;
  80481. set formuparam(value: number);
  80482. get stepsize(): number;
  80483. set stepsize(value: number);
  80484. get zoom(): number;
  80485. set zoom(value: number);
  80486. get tile(): number;
  80487. set tile(value: number);
  80488. get brightness(): number;
  80489. set brightness(value: number);
  80490. get darkmatter(): number;
  80491. set darkmatter(value: number);
  80492. get distfading(): number;
  80493. set distfading(value: number);
  80494. get saturation(): number;
  80495. set saturation(value: number);
  80496. /**
  80497. * Serializes this starfield procedural texture
  80498. * @returns a serialized starfield procedural texture object
  80499. */
  80500. serialize(): any;
  80501. /**
  80502. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80503. * @param parsedTexture defines parsed texture data
  80504. * @param scene defines the current scene
  80505. * @param rootUrl defines the root URL containing startfield procedural texture information
  80506. * @returns a parsed Starfield Procedural BABYLON.Texture
  80507. */
  80508. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80509. }
  80510. }
  80511. declare module BABYLON {
  80512. /** @hidden */
  80513. export var woodProceduralTexturePixelShader: {
  80514. name: string;
  80515. shader: string;
  80516. };
  80517. }
  80518. declare module BABYLON {
  80519. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80520. private _ampScale;
  80521. private _woodColor;
  80522. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80523. updateShaderUniforms(): void;
  80524. get ampScale(): number;
  80525. set ampScale(value: number);
  80526. get woodColor(): BABYLON.Color3;
  80527. set woodColor(value: BABYLON.Color3);
  80528. /**
  80529. * Serializes this wood procedural texture
  80530. * @returns a serialized wood procedural texture object
  80531. */
  80532. serialize(): any;
  80533. /**
  80534. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80535. * @param parsedTexture defines parsed texture data
  80536. * @param scene defines the current scene
  80537. * @param rootUrl defines the root URL containing wood procedural texture information
  80538. * @returns a parsed Wood Procedural BABYLON.Texture
  80539. */
  80540. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80541. }
  80542. }